簡體   English   中英

Android ListView和意圖問題

[英]Android ListView and Intents Issue

我正在構建一個簡單的菜單驅動的應用程序,而我實現的意圖給我帶來了一些問題。

我有3個菜單。 Menu1需要將信息傳遞給Menu2,而Menu2需要將信息從Menu1和Menu2傳遞給Menu3。 為此,我在這種意義上使用Intent。

    String product = ((TextView) view).getText().toString();

    // Launching new Activity on selecting single List Item
    Intent i = new Intent(getApplicationContext(), AccountList.class);
    // sending data to new activity
    i.putExtra("product", product);
    startActivity(i);

這應該將ListSelection傳遞給下一個Activity,即AccountList和AccountList將相同的信息傳遞給SingleListItem,如下所示

    TextView txtProduct = (TextView) findViewById(R.id.list_label);

    Intent i = getIntent();
    // getting attached intent data
    String product = i.getStringExtra("product");
    // displaying selected product name
    txtProduct.setText(product);

現在,上面應該顯示AccountList中的ListSelection,但是,事實並非如此。 您可以提供的任何幫助將不勝感激。

嘗試致電

i.getExtras().getString("product");

代替

i.getStringExtra("product");

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM