0
我有一個onItemonClick
聽者ListView
:異常與一個ListView OnItemClickListener
@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
有關如何解決這個問題的任何建議?