我有ListView
一个onItemonClick
听众:
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
TextView rowName = (TextView)arg1.findViewById(R.id.list_friends_friends_tab_name);
ImageView rowProfilePicture = (ImageView) arg1.findViewById(R.id.list_profile_picture);
CharSequence userName = rowName.getText();
Drawable userProfilePicture = rowProfilePicture.getDrawable();
AlertDialog.Builder menuBuilder = new AlertDialog.Builder(this);
View menuView = getLayoutInflater().inflate(R.layout.menu_friend, (ViewGroup) getCurrentFocus());
menuBuilder.setView(menuView);
menuBuilder.setCancelable(true);
TextView name = (TextView) menuView.findViewById(R.id.menu_user_name);
ImageView profilePicture = (ImageView) menuView.findViewById(R.id.menu_profile_picture);
name.setText(userName);
profilePicture.setImageDrawable(userProfilePicture);
AlertDialog menu = menuBuilder.create();
menu.setCanceledOnTouchOutside(true);
menu.show();
}
当用户单击一个项目时,它应该向他显示一个AlertDialog
具有自定义布局的(菜单),从单击项目的视图中获取一些详细信息并在菜单布局中更改它。我得到一个:
java.lang.UnsupportedOperationException: addView(View, LayoutParams) is not supported in AdapterView
关于如何解决这个问题的任何建议?