私のプロジェクトには、異なる行を持つ SQLite DB があります。現在ListView
、このデータベースの特定の項目を表示する があります。これらのリスト項目には、行nameとcity (コード名taskNameおよびtaskDate 内) のみが表示されます。これらのアイテムをクリックすると、これらのアイテムの「詳細」ページが表示されます。したがって、詳細ページには、「名前」と「都市」だけでなく、クリックされたアイテムのすべての行が含まれている/表示されている必要があります。これまでのところ、これを実行しましたが、名前と都市だけが を介して詳細アクティビティに表示されます.getText()
。で取得しているこれらの 2 行ですがintent.putExtra()
、他の行を表示する方法がわかりませ.getText()
んListView
。
これは私のコードですListAdapter
(さらにコードが必要な場合は教えてください):
public class ServiceAdapter extends ArrayAdapter<ServiceItem> {
private List<ServiceItem> taskList;
private Context context;
public ServiceAdapter(Context context, List<ServiceItem> listItems) {
super(context, R.id.listitem_taskitem, listItems);
this.context = context;
this.taskList = listItems;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
if (v == null) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = inflater.inflate(R.layout.service_task_list, null);
}
ServiceItem task = taskList.get(position);
if (task != null) {
TextView taskName = (TextView) v.findViewById(R.id.task_name);
TextView taskDate = (TextView) v.findViewById(R.id.task_date);
taskName.setText(task.getCity());
taskDate.setText(task.getName());
}
return v;
}
}
これは、これまでの詳細なアクティビティです。
public class ServiceDetails extends Activity {
private TextView city;
private TextView name2;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setupUI();
Bundle extras = getIntent().getExtras();
String name = extras.getString("name").toString();
String description = extras.getString("description").toString();
city.setText(name);
name2.setText(description);
}
private void setupUI() {
setContentView(R.layout.activity_service_details);
city = (TextView) findViewById(R.id.detailName);
name2 = (TextView) findViewById(R.id.detailWww);
}
}