AlertDialog.Builder builderSingle = new AlertDialog.Builder(YourActivity.this);
List<Requests> requester = new ArrayList<>();
final NameAdapter AlertDialogueAdapter = new NameAdapter(this, R.layout.your_custom_layout, requester);
AlertDialogueBuilder.add(new Requests("Hello","StackOverF"))
builderSingle.setIcon(R.drawable.avatar);
builderSingle.setTitle("Select Message by,");
builderSingle.setNegativeButton("cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
finish();
}
});
builderSingle.setAdapter(AlertDialogueAdapter, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Requests req = AlertDialogueAdapter.getItem(which);
AlertDialog.Builder builderInner = new AlertDialog.Builder(ViewSpecialMessage.this);
builderInner.setMessage(req.getKey());
builderInner.setTitle(req.getName());
builderInner.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,int which) {
dialog.dismiss();
}
});
builderInner.show();
}
});
builderSingle.show();
public class Requests{
private String name;
private String key;
public Requests(){
}
public Requests(String name, String key){
this.name = name;
this.key = key;
}
public String getName() {
return name;
}
public String getKey() {
return key;
}
}
public class NameAdapter extends ArrayAdapter<Requests>{
public NameAdapter(Context context, int resource, List<Requests> objects) {
super(context, resource, objects);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = ((Activity) getContext()).getLayoutInflater().inflate(R.layout.name_adapter_layout, parent, false);
}
final Requests message = getItem(position);
TextView NameOfRequester = (TextView) convertView.findViewById(R.id.RequesterName);
ImageView ImgOfRequester = (ImageView) convertView.findViewById(R.id.RequesterImage);
NameOfRequester.setText(message.getName());
return convertView;
}
}
ここにいくつかのコードをダンプしましたが、あなたの質問は何ですか?あなたは何を達成したいのですか?あなたが直面している問題は何ですか? –