0

私のプロジェクトには、異なる行を持つ SQLite DB があります。現在ListView、このデータベースの特定の項目を表示する があります。これらのリスト項目には、行namecity (コード名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);
    }
}
4

1 に答える 1

0

あなたは自分が何をしているのかわからないようです:P アダプターに提供された ServiceItem リストがあり、それを表示します。

これらのアイテムにデータベースからフェッチされたすべてのデータが含まれている場合、シリアル化されたオブジェクトまたはそのすべてのデータをServiceDetailsアクティビティに渡すことができます。

これらの項目に名前と都市に関する情報のみが含まれている場合、次の 2 つのオプションがあります。

  • 名前と都市を入力するときは、このデータを入力します (大きすぎない場合)。
  • ServiceDetails アクティビティでは、名前/ID または取得できるものによって、データベースからオブジェクトを取得します。
于 2013-11-06T16:17:40.223 に答える