Java 如何从列表视图中获取复选框值。。。哪个连接到Sqlite数据库?
帮助获取手机号码并在编辑文本中获取它。。。我走了 请帮助我获取复选框值并将手机号码带到某个位置。使用sms管理器发送sms 类名适配器。。。其中包含列表视图的行Java 如何从列表视图中获取复选框值。。。哪个连接到Sqlite数据库?,java,android,sqlite,Java,Android,Sqlite,帮助获取手机号码并在编辑文本中获取它。。。我走了 请帮助我获取复选框值并将手机号码带到某个位置。使用sms管理器发送sms 类名适配器。。。其中包含列表视图的行 List list=new ArrayList(); Context context; public Adapter(Context context, int resource) { super(context, resource); this.context=context; } public void ad
List list=new ArrayList();
Context context;
public Adapter(Context context, int resource)
{
super(context, resource);
this.context=context;
}
public void add(Product object) {
list.add(object);
super.add(object);
}
@Override
public int getCount() {
return list.size();
}
@Override
public Object getItem(int position) {
return list.get(position);
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
View row=convertView;
final Holder holder;
if (row==null){
LayoutInflater layoutInflater= (LayoutInflater) this.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
row=layoutInflater.inflate(R.layout.rowlist,parent,false);
holder =new Holder();
holder.id=(TextView)row.findViewById(R.id.tsnoo);
holder.name=(TextView)row.findViewById(R.id.tname);
holder.birth=(TextView)row.findViewById(R.id.tbirth);
holder.email=(TextView)row.findViewById(R.id.temail);
holder.req=(TextView)row.findViewById(R.id.treq);
holder.mobile=(TextView)row.findViewById(R.id.tmobile);
holder.check=(CheckBox)row.findViewById(R.id.tcheck);
row.setTag(holder);
}else {
holder= (Holder) row.getTag();
}
Product product= (Product) getItem(position);
holder.id.setText(Integer.toString(product.getId()));
holder.name.setText(product.getName().toString());
holder.birth.setText(product.getBirth().toString());
holder.email.setText(product.getEmail().toString());
holder.req.setText(product.getReq().toString());
holder.mobile.setText(product.getMobile().toString());
holder.check.setChecked(false);
holder .check.setChecked(itemChecked[position]);
holder.check.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
itemChecked[position]=isChecked;
}
});
return row;
}
private boolean[] itemChecked;
private void createCheckedHolder() {
itemChecked = new boolean[getCount()];
}
static class Holder{
TextView name,birth,email,req,mobile,id;
CheckBox check;
}
}
我使用AsyncTask来同步它…在这里,我自己给出了答案。。。用简单的方法
holder.check.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if(holder.check.isChecked()){
View get=null;
for (int i=0;i<getCount();i++) {
if (position == i) {
get = getView(i, get, listView1);
holder.mobile = (TextView) get.findViewById(R.id.tmobile);
String last = holder.mobile.getText().toString();
String[] data;
Toast.makeText(getContext(), last, Toast.LENGTH_SHORT).show();
}
}
}
else
{
}
}
});
holder.check.setOnCheckedChangeListener(新建CompoundButton.OnCheckedChangeListener(){
@凌驾
检查更改后的公共无效(复合按钮视图,布尔值已检查){
if(holder.check.isChecked()){
View get=null;
对于(int i=0;我不打算在你没有告诉我应该做什么的情况下通读那么多代码试图理解它。如果你不能缩小你的问题范围,恐怕我们无法帮助你。还有,你做了什么研究?所以我想,试图帮助你的人不仅仅是重复你已经知道的。