Dialog
基本用法 ,带自定义view
AlertDialog dialog = new AlertDialog.Builder(context).setTitle("写入信息") .setView(view) .setPositiveButton("确认", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }).setNegativeButton("取消", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) {
} }) .create(); dialog.show();
自定义 Adapter
public final class ViewHolder { public TextView describe; public TextView username; public TextView password; } @Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder=null; if (convertView==null){ holder = new ViewHolder(); convertView=mInflater.inflate(R.layout.adapter_account_item,null); holder.describe=(TextView)convertView.findViewById(R.id.describe); holder.username=(TextView)convertView.findViewById(R.id.username); holder.password=(TextView)convertView.findViewById(R.id.password); convertView.setTag(holder); }else{ holder = (ViewHolder) convertView.getTag(); } holder.describe.setText(listdata.get(position).getDescribe()); holder.username.setText(listdata.get(position).getAccount()); holder.password.setText(listdata.get(position).getPassword()); return convertView; }
原文:http://www.cnblogs.com/baokang/p/4970091.html