你如何做到这一点?

发布于 2024-12-09 22:43:06 字数 499 浏览 1 评论 0原文

这就是我定义的列表视图数组。

private String lv_arr[] = {"number1", "number2", "number3", "number4"};

如何更改它们以链接到 number1.javanumber2.javanumber3.javanumber4.java?

[已编辑]

链接:http://pastebin.com/BH8N4dKb

[已编辑] http://pastebin.com/GjrBj2m5

现在我没有错误,但它仍然没有任何其他内容。

This is what I defined as my listview array.

private String lv_arr[] = {"number1", "number2", "number3", "number4"};

How can I change those to be linked to number1.java, number2.java, number3.java and number4.java?

[Edited]

Link : http://pastebin.com/BH8N4dKb

[Edited]
http://pastebin.com/GjrBj2m5

now i have no error, but it still does not have anything else.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

过度放纵 2024-12-16 22:43:06

像这样使用。

setListAdapter(new ArrayAdapter(this, android.R.layout.simple_expandable_list_item_1, Categories));
    ListView lv = getListView();      
lv.setTextFilterEnabled(true);
    lv.setOnItemClickListener(new OnItemClickListener() {
          public void onItemClick(AdapterView<?> parent, View v,int position, long id) {

              switch (position){
              case 0: Intent animalsGridViewIntent = new Intent(ListOfAppGallery.this,N1.class);     
                      ListOfAppGallery.this.startActivity(animalsGridViewIntent);
                      break;
              case 1: Intent calenderGridViewIntent = new Intent(ListOfAppGallery.this,N2.class);     
                      ListOfAppGallery.this.startActivity(calenderGridViewIntent);
                      break;
              case 2: Intent carsGridViewIntent = new Intent(ListOfAppGallery.this,N3.class);     
                      ListOfAppGallery.this.startActivity(carsGridViewIntent);
                      break;
              case 3: Intent creativeGridViewIntent = new Intent(ListOfAppGallery.this,N4.class);     
                      ListOfAppGallery.this.startActivity(creativeGridViewIntent);
                      break;

          }
      }
   });    
}

use like this.

setListAdapter(new ArrayAdapter(this, android.R.layout.simple_expandable_list_item_1, Categories));
    ListView lv = getListView();      
lv.setTextFilterEnabled(true);
    lv.setOnItemClickListener(new OnItemClickListener() {
          public void onItemClick(AdapterView<?> parent, View v,int position, long id) {

              switch (position){
              case 0: Intent animalsGridViewIntent = new Intent(ListOfAppGallery.this,N1.class);     
                      ListOfAppGallery.this.startActivity(animalsGridViewIntent);
                      break;
              case 1: Intent calenderGridViewIntent = new Intent(ListOfAppGallery.this,N2.class);     
                      ListOfAppGallery.this.startActivity(calenderGridViewIntent);
                      break;
              case 2: Intent carsGridViewIntent = new Intent(ListOfAppGallery.this,N3.class);     
                      ListOfAppGallery.this.startActivity(carsGridViewIntent);
                      break;
              case 3: Intent creativeGridViewIntent = new Intent(ListOfAppGallery.this,N4.class);     
                      ListOfAppGallery.this.startActivity(creativeGridViewIntent);
                      break;

          }
      }
   });    
}
南薇 2024-12-16 22:43:06

抓住你的列表视图:
listView.setOnItemOnClickListener() 并检查是否启动新活动:

listView.setOnItemClickListener(new OnItemClickListener(){

                @Override
                public void onItemClick(AdapterView<?> arg0, View view, int position,long id) {
                                        Intent intent;
                    switch (position) {
                    case 1:
                        intent=new Intent(getApplicationContext(),NumberOne.java)
                        getApplicationContext().startActivity(intent);
                        break;
                    case 2:
                        intent=new Intent(getApplicationContext(),NumberTwo.java);
                        getApplicationContext().startActivity(intent);
                        break;
                    case 3:
                        intent=new Intent(getApplicationContext(),NumberThree.java);
                        getApplicationContext().startActivity(intent);
                        break;
                    case 4:
                        intent=new Intent(getApplicationContext(),NumberFour.java);
                        getApplicationContext().startActivity(intent);
                        break;
                    default:
                        break;
                    }
                }

});

Catch on your listview :
listView.setOnItemOnClickListener() and check for the check for the case to start a new activity:

listView.setOnItemClickListener(new OnItemClickListener(){

                @Override
                public void onItemClick(AdapterView<?> arg0, View view, int position,long id) {
                                        Intent intent;
                    switch (position) {
                    case 1:
                        intent=new Intent(getApplicationContext(),NumberOne.java)
                        getApplicationContext().startActivity(intent);
                        break;
                    case 2:
                        intent=new Intent(getApplicationContext(),NumberTwo.java);
                        getApplicationContext().startActivity(intent);
                        break;
                    case 3:
                        intent=new Intent(getApplicationContext(),NumberThree.java);
                        getApplicationContext().startActivity(intent);
                        break;
                    case 4:
                        intent=new Intent(getApplicationContext(),NumberFour.java);
                        getApplicationContext().startActivity(intent);
                        break;
                    default:
                        break;
                    }
                }

});

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文