我怎样才能让我的提醒对话android.please自定义提醒帮助我在自定义提醒中显示我的对话框。我的代码粘贴在这里。该代码包含10列表视图的输出。当点击列表中的项目时,它可能会收到警告..我怎样才能让我的提醒对话在Android的自定义提醒
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Find the ListView resource.
mainListView = (ListView) findViewById(R.id.mainListView);
// Create and populate a List of planet names.
final String[] planets = new String[] { "Allu", "Abin", "Bibin", "Aswathy",
"Jibin", "Saran", "Jobin", "Neethu","ammu","Ram"};
final ArrayList<String> planetList = new ArrayList<String>();
planetList.addAll(Arrays.asList(planets));
// Create ArrayAdapter using the planet list.
listAdapter = new ArrayAdapter<String>(this, R.layout.simplerow, planetList);
/*// Add more planets. If you passed a String[] instead of a List<String>
// into the ArrayAdapter constructor, you must not add more items.
// Otherwise an exception will occur.
listAdapter.add("Ceres");
listAdapter.add("Pluto");
listAdapter.add("Haumea");
listAdapter.add("Makemake");
listAdapter.add("Eris");*/
// Set the ArrayAdapter as the ListView's adapter.
mainListView.setAdapter(listAdapter);
mainListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, final int position, long id) {
AlertDialog.Builder alert = new AlertDialog.Builder(context);
alert.setTitle("Alert Dialog With EditText"); //Set Alert dialog title here
alert.setMessage("Edit Your Name Here"); //Message here
final EditText input = new EditText(context);
input.setText((String)planetList.get(position));
alert.setView(input);
alert.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
String srt = input.getEditableText().toString();
Toast.makeText(context,srt, Toast.LENGTH_LONG).show();
planetList.set(position, srt);
listAdapter.notifyDataSetChanged();
}
});
alert.setNegativeButton("CANCEL", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
dialog.cancel();
}
}); //End of alert.setNegativeButton
AlertDialog alertDialog = alert.create();
alertDialog.show();
}
});
}
}
你想为你的对话框设计一个XML布局吗? – Bimbow 2015-02-24 11:29:27
我想在自定义提醒格式中看到我的提醒 – Anoop 2015-02-24 11:35:44
我需要为自定义提醒创建另一个xml文件吗 – Anoop 2015-02-24 11:50:33