主要活动代码public class MainActivity extends Activity implements OnItemClickListener, OnClickListener{Button send;ListView listViewSMS;Cursor cursor;SMSListAdapter smsListAdapter;Context context;ArrayAdapter<SMSListModel> adapter;List<SMSListModel> list = new ArrayList<SMSListModel>();TextView textViewSMSSender, textViewSMSBody;int i;int count = 0;@Overrideprotected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); context=this; listViewSMS=(ListView)findViewById(R.id.lvSMS); send = (Button)findViewById(R.id.send); send = (Button)findViewById(R.id.send); textViewSMSSender=(TextView)findViewById(R.id.tvSMSSend); textViewSMSBody=(TextView)findViewById(R.id.tvSMSBody); cursor = getContentResolver().query(Uri.parse("content://sms/inbox"), null, null, null, null); smsListAdapter = new SMSListAdapter(this,getModel()); listViewSMS.setAdapter(smsListAdapter); listViewSMS.setOnItemClickListener(this);}@Overridepublic void onItemClick(AdapterView<?> arg0, View v, int arg2, long arg3) { TextView label = (TextView) v.getTag(R.id.tvSMSSend); CheckBox checkbox = (CheckBox) v.getTag(R.id.cbSelect); Toast.makeText(v.getContext(), label.getText().toString()+" "+isCheckedOrNot(checkbox), Toast.LENGTH_LONG).show(); }private String isCheckedOrNot(CheckBox checkbox) { if(checkbox.isChecked()) return "is checked"; else return "is not checked";}private List<SMSListModel> getModel() { if(cursor.getCount()>0){ for(i=0;i<cursor.getCount();i++){ if(cursor.moveToPosition(i)){ list.add(new SMSListModel(cursor.getString(cursor.getColumnIndex("address")),cursor.getString(cursor.getColumnIndex("body")))); } } } return list;}我想使用复选框选择发送多个短信。仅将选定短信的内容(即它们的主体)作为新的消息主体发送到已预定义的#121,但是上述代码在执行选择后将完整的收件箱消息(无论是否选中)发送到121。
1 回答
- 1 回答
- 0 关注
- 783 浏览
添加回答
举报
0/150
提交
取消