我怎樣才能讓我的提醒對話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