开发者

How do you do this? [closed]

开发者 https://www.devze.com 2023-04-12 18:44 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form. For help clari
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 开发者_StackOverflow社区11 years ago.

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.


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;

          }
      }
   });    
}


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;
                    }
                }

});

0

精彩评论

暂无评论...
验证码 换一张
取 消