在長按監聽之後,彈出個dialog,裡面包含有editext 如何能使長按的item的文本內容改變為editext輸入的內容呢?
代碼:@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
//這是點擊的item的文本內容 如何才能在點擊確定按鈕之後改變item的文本內容呢?
String str = list.get(position);
showDialog();
RenameTitle(position);
return true;
}
private AlertDialog d;
private void showDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
View layout = getLayoutInflater().inflate(R.layout.managerrss_dialog_layout, null);
TextView tvRename = (TextView) layout.findViewById(R.id.manager_rss_dialog_rename);
TextView tvDelete = (TextView) layout.findViewById(R.id.manager_rss_dialog_delete);
builder.setView(layout);
tvRename.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
d.dismiss();
showDialog1();
}
});
tvDelete.setOnClickListener(this);
d = builder.create();
d.show();
}
private AlertDialog dd;
private void showDialog1() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
View layout = getLayoutInflater().inflate(R.layout.managerrss_dialog_layout_rename, null);
final EditText etRename = (EditText) layout.findViewById(R.id.manager_rss_dialog_et_name);
builder.setTitle(getResources().getString(R.string.rename));
builder.setView(layout);
builder.setPositiveButton(getResources().getString(R.string.sure), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
//這個是輸入框輸入的內容
ReTitle = etRename.getText().toString();
dd.dismiss();
}
});
builder.setNegativeButton("取消", null);
dd = builder.create();
dd.show();
}
解決了 我把自己繞暈了 用個全局變量記錄當前點擊的item的內容 然後......然後 他媽的直接賦值就可以了 不要鄙視我 QvQ