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);
}
}
}
看到这个我也在列表视图项目点击上显示对话框。
您没有设置警报对话框视图以显示某些内容的问题,您应该为其分配一些布局以在警报对话框中显示。试试看。