我有一個editText的列表視圖,當我在這些editText中顯示數據時,我將editText設置爲禁用,之後我創建了一個彈出菜單,其中我編輯了項目以修改數據,所以當我點擊它時,我啓用了editText 。 我嘗試了關於啓用/禁用edittext的所有解決方案。但它不起作用。 :如何從彈出菜單啓用editText?
我的屏幕的ListView:
來源:
public View getView(int position, View convertView, final ViewGroup parent) {
final int pos = position;
if (inflater == null)
inflater = (LayoutInflater) activity
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if (convertView == null)
convertView = inflater.inflate(R.layout.feed_item, null);
name = (EditText) convertView.findViewById(R.id.name_book_display);
statusMsg = (EditText) convertView.findViewById(R.id.desc_display);
prix = (EditText) convertView.findViewById(R.id.prix_display);
disableEditText(name);
disableEditText(statusMsg);
disableEditText(prix);
popupMenu.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
IconizedMenu popup = new IconizedMenu(parent.getContext(), view);
MenuInflater inflater = popup.getMenuInflater();
inflater.inflate(R.menu.poupup_menu, popup.getMenu());
popup.setOnMenuItemClickListener(new IconizedMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()) {
case R.id.update_book:
enableEditText(name);
enableEditText(statusMsg);
enableEditText(prix);
updateBtn.setVisibility(View.VISIBLE);
return true;
case R.id.add_book_to_favoris:
return true;
case R.id.delete_book:
return true;
default:
return false;
}
}
}
);
popup.show();
}
});
return convertView;
}
private void disableEditText(EditText editText) {
editText.setFocusable(false);
editText.setEnabled(false);
editText.setCursorVisible(false);
editText.setKeyListener(null);
editText.setBackgroundColor(Color.TRANSPARENT);
}
private void enableEditText(EditText editText) {
editText.setFocusable(true);
editText.setEnabled(true);
editText.setCursorVisible(true);
editText.setKeyListener(listener);
}
嘗試登錄了'disableEditText'和'enableEditText'只是爲了看看他們被稱爲 –
@OmarAlHalabi檢查我調試它的更新,它們被稱爲 – Amal