2
I would like to know how to create a AlertDialog
like the one in the image (with keyboard) on Android. Thank you.
Keyboard:
<Button
android:id="@+id/dois"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2"
/>
<Button
android:id="@+id/tres"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="3"
/>
</TableRow>
<TableRow>
<Button
android:id="@+id/quatro"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="4"
/>
<Button
android:id="@+id/cinco"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="5"
/>
<Button
android:id="@+id/seis"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="6"
/>
</TableRow>
<TableRow>
<Button
android:id="@+id/sete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="7"
/>
<Button
android:id="@+id/oito"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="8"
/>
<Button
android:id="@+id/nove"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="9"
/>
</TableRow>
<TableRow>
<Button
android:id="@+id/excluir"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="excluir"
/>
<Button
android:id="@+id/zero"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0"
/>
<Button
android:id="@+id/igual"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="="
/>
</TableRow>
</TableLayout>
Alertdialog:
AlertDialog.Builder builder = new AlertDialog.Builder(this);
LayoutInflater inflater = this.getLayoutInflater();
builder.setView(inflater.inflate(R.layout.insertnum, null))
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
// sign in the user ...
}
})
.setNegativeButton(R.string.cancelar, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
//
}
});
builder.create();
builder.show();
}
You can build a keyboard using a
GridLayout
or theTableLayout
, I think this question can help you get started: http://answall.com/questions/33393/como-crea-bot%C3%B5es-with-size-din%C3%A2mico-em-xml.– Wakim
The Keyboard itself I managed to do, but when I press the numbers they do not appear on the screen, what I am not able to do =/
– Daniel Ferrari
Could you include your code? At first it seems a problem of listening to click event and change the
TextView
.– Wakim