This is my pop-out windows that I want to show the chat.
I create a AlertDialog.Builder which can't click item by using isEnabled.
And don't dismiss after click PositiveButton by override the positive button's handler.
Is it possible to scroll the list to the end when I update my ArrayAdapter ?
I want to show the latest words but I only find the answer about listView.
My code is below. Thank you for helping me.
listWords = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1) {
public boolean isEnabled(int position) {
return false;
}
};
AlertDialog.Builder sayWindows = new AlertDialog.Builder(MapActivity.this);
final EditText saySomething = new EditText(MapActivity.this);
sayWindows.setPositiveButton("Say!", null);
sayWindows.setNegativeButton("cancel", null);
sayWindows.setAdapter(listWords, null);
sayWindows.setView(saySomething);
final AlertDialog mAlertDialog = sayWindows.create();
mAlertDialog.setOnShowListener(new DialogInterface.OnShowListener() {
public void onShow(DialogInterface dialog) {
Button positive = mAlertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
positive.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
listWords.add(userName + ": " + saySomething.getText());
}
});
}
});
mAlertDialog.show();
0 comments:
Post a Comment