没有人知道您如何通过textinput(因此从绿色变为粉红色)更改textinputline和AlertDialog的光标。1]:https://i.stack.imgur.com/1apfI.png我像这样在我的班上实现它:
AlertDialog.Builder builder = new AlertDialog.Builder(this,R.style.AlertDialogTheme); builder.setTitle("Artikel Toevoegen"); final EditText input = new EditText(this); input.setSingleLine(); builder.setView(input); builder.setPositiveButton("Toevoegen", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if(input.length() != 0) { shoppingList.add((input.getText().toString())); lv.setAdapter(adapter); } else { Toast toast = Toast.makeText(getApplicationContext(),"Voer een artikel in", Toast.LENGTH_LONG); toast.setGravity(Gravity.CENTER, 0, 570); toast.show(); artikelToevoegen(); } } }); builder.setNegativeButton("Annuleer", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); AlertDialog dialog = builder.create(); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); WindowManager.LayoutParams wmlp = dialog.getWindow().getAttributes(); wmlp.gravity = Gravity.TOP | Gravity.LEFT; wmlp.x = 40; //x position wmlp.y = 100; //y position dialog.show();
这就是xml样式的样子:
<style name="AlertDialogTheme" parent="ThemeOverlay.AppCompat.Dialog.Alert">
android:textCursorDrawable="@drawable/pink_cursor"
android:backgroundTint="#D70F64"
<item name="buttonBarNegativeButtonStyle">@style/NegativeButtonStyle</item>
<item name="buttonBarPositiveButtonStyle">@style/PositiveButtonStyle</item>
</style>
<style name="NegativeButtonStyle" parent="Widget.AppCompat.Button.ButtonBar.AlertDialog">
<item name="android:textColor">#d70f64</item>
</style>
<style name="PositiveButtonStyle" parent="Widget.AppCompat.Button.ButtonBar.AlertDialog">
<item name="android:textColor">#d70f64</item>
</style>
没有人知道您如何通过textinput(因此从绿色变为粉红色)更改textinputline和AlertDialog的光标。 1]:https://i.stack.imgur.com/1apfI.png我在我的类中实现了这样的代码:...
您可以更改颜色,