我正在使用 SimpleCursoradapter 填充我在活动中拥有的列表。
现在我需要将此活动的字符串值传递给另一个活动,并且该值将从本地数据库中获取。
我通过在列表视图中创建一个新的文本视图并使用 SimpleCursorAdapter 映射字符串值来做了同样的事情。
这是最好的做法吗?
public class InboxAdapter extends SimpleCursorAdapter {
public InboxAdapter(Context context, int layout, Cursor c,
String[] from, int[] to) {
super(context, layout, c, from, to);
}
@Override
public void bindView(View view, Context context, Cursor cursor) {
super.bindView(view, context, cursor);
Button msgReply = (Button) view.findViewById(R.id.msgReply);
final TextView msgId = (TextView) view.findViewById(R.id.msgId);
msgReply.setOnClickListener(new View.OnClickListener() {
private Intent intent;
@Override
public void onClick(View v) {
intent = new Intent(getApplicationContext(), ComposeMessage.class);
Bundle b = new Bundle();
b.putCharSequence("id", msgId.getText());
intent.putExtras(b);
startActivity(intent);
}
});
}
}