Search Results

Search found 1 results on 1 pages for 'ricardo123'.

Page 1/1 | 1 

  • displaying a dialog using an activity?

    - by ricardo123
    what am i doing wrong here or what do i need to add? package dialog.com; import android.app.Activity; import android.app.AlertDialog; import android.content.DialogInterface; import android.app.Dialog; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.Toast; public class Dialog extends Activity { CharSequence [] items = { "google", "apple", "microsoft" }; boolean [] itemschecked = new boolean [items.length]; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button btn = (Button) findViewById(R.id.btn_dialog); btn.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDialog(0); } }); } @Override protected Dialog onCreateDialog(int id) { switch(id) { case 0: return new AlertDialog.Builder(this) .setIcon(R.drawable.icon) .setTitle("This is a Dialog with some simple text...") .setPositiveButton("ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichbutton) { Toast.makeText(getBaseContext(), "OK Clicked!", Toast.LENGTH_SHORT).show(); } }); .setNegativeButton("cancel",new DialogInterface.OnclickListener() { public void onClick(DialogInterface dialog, int whichButton) {Toast.makeText(getBaseContext(), "cancel clicked!", Toast.LENGTH_SHORT).show(); } }); .setMultiChoiceItems(itemschecked, new DialogInterface.OnMultiChoiceClickListener() { @Override public void onClick(dialoginterface dialog, int which, boolean isChecked) { Toast.makeText(getBaseContext(), items[which] + (isChecked ? " checked!": "unchecked!"), Toast.LENGTH_SHORT).show(); } } ) .create(); } return null: }}}

    Read the article

1