0
我只想將TextView
變成EditText
的輸入,但它不起作用。此外,這是在一個自定義陣列適配器不是Activity
,如果這有所作爲。此外,我有它的工作,我改變了方向AndroidManifest.xml
然後我改回它的默認和EditText
輸入不再改變TextView
。如何從alertDialog中將editText輸入設置爲textView
我甚至使用VCS本地歷史回到我以前的代碼我不知道發生了什麼。這是我的代碼。上面的OnCreate
class CustomAdapter extends ArrayAdapter{
public CustomAdapter(Context context, ArrayList choreText) {
super(context, R.layout.custon_listview_row, choreText);
}
@NonNull
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater myInflater = LayoutInflater.from(getContext());
View customView = myInflater.inflate(R.layout.custon_listview_row, parent, false);
ImageButton imageButton = (ImageButton) customView.findViewById(R.id.imageButton_ID);
final TextView textView = (TextView) customView.findViewById(R.id.textView_ID);
final EditText input = new EditText(getContext());
final AlertDialog OptionDialog = new AlertDialog.Builder(getContext()).create();
// makes textView clickable
textView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//what happens when textView is clicked
//final AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
// put aler dialog box logic here
OptionDialog.setTitle("Enter new chore");
OptionDialog.setView(input);
input.setInputType(InputType.TYPE_CLASS_TEXT);
input.setImeOptions(EditorInfo.IME_ACTION_DONE);
//checks if "Done" button on soft keyboard is clicked
input.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if(actionId==EditorInfo.IME_ACTION_DONE){
//what happens when "Done" is clicked
textView.setText(input.getText().toString());
OptionDialog.dismiss();
}
return false;
}
});
OptionDialog.show();
}
});
imageButton.setImageResource(R.drawable.clock);
return customView;
}
}
「它不工作」它有多遠?它是崩潰還是什麼? –
它全部工作只是textView不會更改爲用戶輸入。它保持不變。 –
然後檢查是否(actionId == EditorInfo.IME_ACTION_DONE){//}天氣這個塊執行放在這裏面的第一行日誌,看看它是否被稱爲 –