【发布时间】:2015-02-10 22:16:37
【问题描述】:
我正在尝试制作启动器。 我已经显示了带有 app_label、icon、package_name 和复选框的自定义列表。 现在我想将选定的 app_name 保存在共享首选项中。 我不知道如何通过它。 请帮忙。
这是我的代码:
adapter = new ArrayAdapter<AppDetail>(MainActivity.this,
android.R.layout.simple_list_item_multiple_choice, apps) {
@Override
public View getView(int position, View convertView,
ViewGroup parent) {
View row = convertView;
if (row == null) {
convertView = getLayoutInflater().inflate( R.layout.list_item,parent,false);
}
// check_checkbox();
k=apps.get(position);
ImageView appIcon = (ImageView) convertView
.findViewById(R.id.item_app_icon);
appIcon.setImageDrawable(k.icon);
TextView appLabel = (TextView) convertView
.findViewById(R.id.item_app_label);
appLabel.setText(k.label);
TextView appName = (TextView) convertView
.findViewById(R.id.item_app_name);
appName.setText(k.name);
final String ss;
ss = k.name;
ch = (CheckBox) convertView.findViewById(R.id.c1);
ch .setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean b) {
}
});
ch.setChecked(apps.get(position).c1);
return convertView;
}
};
【问题讨论】:
-
那么您是否使用此代码获取选定的应用程序?
标签: android listview checkbox sharedpreferences android-custom-view