void showDialog() {
new AlertDialog.Builder(this)
.setTitle(R.string.title)
.setAdapter(new DemoAdapter(this), new onClickListener(){
@Override
public void onClick(DialogInterface dialog, int which) {
//todo
}
}).show();
}
private class DemoAdapter extends BaseAdapter{
LayoutInflater layInflater;
ShareAdapter(Context context) {
layInlater = LayoutInflater.from(context);
}
@Override
public int getCount() {
return 2;//item个数
}
@Override
public Object getItem(int position) {
return null;
}
@Override
public long getItemId(int position) {
return position;
}
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if(convertView == null) {
convertView = layoutInflater.inflate(R.layout.layout_share_item,(注释: layout 布局) parent, false);
}
TextView textView = (TextView)convertView.findViewById(R.id.share_title);
textView.setText(SHARE_TEXT[position]);注释:textText设值
textView.setCompoundDrawablesRelativeWithIntrinsicBounds(SHARE_ICON[position], 0, 0, 0); 注释:设图片
return convertView;
}
}
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。