主要活動代碼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;}我想使用復選框選擇發(fā)送多個短信。僅將選定短信的內(nèi)容(即它們的主體)作為新的消息主體發(fā)送到已預定義的#121,但是上述代碼在執(zhí)行選擇后將完整的收件箱消息(無論是否選中)發(fā)送到121。
- 1 回答
- 0 關注
- 818 瀏覽
添加回答
舉報
0/150
提交
取消