public void onItemClick(AdapterView<?> adapter, View view, int position, long arg3) {
// TODO Auto-generated method stub
Log.d("postiton", String.valueOf(position));
//switch(position)
//{
//case 0:
if(position==0)
{
if(Session.getActiveSession()==null)
{
Toast.makeText(MainActivity.this, "You must login first", Toast.LENGTH_LONG).show();
}
else
{
dialog=new AlertDialog.Builder(MainActivity.this);
dialog.setTitle("Update Status");
LayoutInflater inflater = (LayoutInflater)getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
dialogView = inflater.inflate(R.layout.update_status, null);
//dialog.
dialog.setView(dialogView);
dialog.setPositiveButton("Update Status", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int ButtonId) {
// TODO Auto-generated method stub
UpdateStatus();
}
});
dialog.show();
}
}
//case 1:
if(position==1)
{
if(Session.getActiveSession()==null)
{
Toast.makeText(MainActivity.this, "You must login first", Toast.LENGTH_LONG).show();
}
else
{
dialog = new AlertDialog.Builder(MainActivity.this);
dialog.setTitle("Upload Photo");
LayoutInflater inflater = (LayoutInflater)getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
dialogView = inflater.inflate(R.layout.post_photo, null);
Button browse = (Button)dialogView.findViewById(R.id.browsePhotoButton);
browse.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent i = new Intent(
Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(i, RESULT_LOAD_IMAGE);
}
});
dialog.setView(dialogView);
dialog.setPositiveButton("Upload Photo", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int ButtonId) {
// TODO Auto-generated method stub
publishStory(image);
}
});
dialog.show();
}
}
if(position==2)
{
if(Session.getActiveSession()==null)
{
Toast.makeText(MainActivity.this, "You must login first", Toast.LENGTH_LONG).show();
}
else
{
Intent friendsActivity = new Intent(MainActivity.this,Friends.class);
startActivity(friendsActivity);
}
}
}
これを参照してください。リストビュー項目のクリック時にダイアログも表示しています。
警告ダイアログのビューを設定して何かを表示していない問題は、警告ダイアログに表示するレイアウトを割り当てる必要があります。それを試してみてください。