我正在开发一个应用程序,使用自定义适配器来管理 ListView。该应用在活动界面中运行。
public class Adapter extends ArrayAdapter {
Context mContext;
int resourceID;
ArrayList<String> names;
public Adapter(Context context, int resource, ArrayList<String> objects) {
super(context, resource, objects);
this.mContext = context;
this.resourceID=resource;
this.names= objects;
}
@Override
public String getItem(int position) {
return names.get(position);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View row = convertView;
LayoutInflater inflater = LayoutInflater.from(mContext);
row = inflater.inflate(resourceID, parent, false);
TextView text = (TextView) row.findViewById(R.id.text);
text.setText(names.get(position));
return row;
}
}
我使用了这段代码来让它们在一个活动中显示。
myNames= (ListView) findViewById(R.id.List);
adapter = new Adapter(this,R.layout.names_view, Current.Names);
myNames.setAdapter(adapter);
现在我想点击一个按钮,使得相同的列表出现在弹出窗口中,请帮忙吗?