我的应用程序将接收 SMS,将其保存在 SQLite 中,然后将其显示在我的列表中。其余的都完成了,但我无法将数据放入我的列表中;我怎样才能做到这一点?
这是我正在尝试的:
list.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View view,
int position, long index) {
// here send Recent case Object OR or Recent case info. to show case information
}
});
这是我的适配器:
public class RecentCaseListAdapter extends BaseAdapter {
private RecentCases myPage;
static public List<RecentCaseClass> listOfCases;
RecentCaseClass entry;
public RecentCaseListAdapter(RecentCases R, List<RecentCaseClass> listOfCaseParameter) {
this.myPage = R;
this.listOfCases = listOfCaseParameter;
}
public int getCount() {
return listOfCases.size();
}
public Object getItem(int position) {
return listOfCases.get(position);
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup viewGroup) {
entry = listOfCases.get(position);
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) myPage.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.recent_cases_row, null);
}
// this is row items..
// Set the onClick Listener on this button
TextView tvCase = (TextView) convertView.findViewById(R.id.tvrecentName);
tvCase.setText(entry.getName());
TextView tvCaseInfo = (TextView) convertView.findViewById(R.id.recent_info);
tvCaseInfo.setText(entry.getAge());
// To be a clickable button
return convertView;
}
public void add(RecentCaseClass rCaseClass) {
// TODO Auto-generated method stub
listOfCases.add(rCaseClass);
}
}
这是我的清单
public static List<RecentCaseClass> RecentCaseList = new ArrayList<RecentCaseClass>();
public static List<RecentCaseClass> getRecentCaseList() {
return RecentCaseList;
}
public static void setRecentCaseList(List<RecentCaseClass> recentCaseList) {
RecentCaseList = recentCaseList;
}
在这里我应该添加到列表中
if (SMSReceived.startsWith("Hi")) {
Toast.makeText(context, "Iam in hi", Toast.LENGTH_LONG)
.show();
msg = SMSReceived;
RecentCaseClass rCase = run();
dbAdapter.add(rCase);
All_Static.RecentCaseList.add(recent1);
}