MacSTD
MacSTD

Reputation: 7

Listview click open little listview

I got a project its a education set. When the project started opening a start page and you are clicking any lesson.lessons showing in listview.Which you clicked a lesson opening that lesson class.but i looked i have +400 lesson's topic.Like this, Biology; Animals,Caenorhabditis elegans: a model organism,Drosophila melanogaster,InvertebratesMonotremes i have +40 lesson like this.i thinked if i click a lesson on listview.it can be open a new listview in same class.like multiple listview ? open a little listview.that will be topics of the clicked lesson. how can i do that pls help :)

    private ListView lv1;
     private String lv_arr[]={"Lessons,Leson1,Leson2,etc..."}; 
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);        
            setContentView(R.layout.konu);

            lv1=(ListView)findViewById(R.id.listView1);
            AdView adView = (AdView) this.findViewById(R.id.adView);
            AdRequest adRequest = new AdRequest.Builder().build();
            adView.loadAd(adRequest);

            lv1=(ListView)findViewById(R.id.listView1);

            // By using setAdpater method in listview we an add string array in list.

            lv1.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1 , lv_arr));     
            lv1.setOnItemClickListener(new OnItemClickListener() {
                public void onItemClick(AdapterView<?> parent, View view,
                    int position, long id) {

        if(position == 0)
        {

                 Intent myIntent = new Intent(soru.this, mat1.class);
                     startActivityForResult(myIntent, 0);
        }

        if(position == 1)
        {

                 Intent myIntent =  new Intent(soru.this, mat2.class);
                     startActivityForResult(myIntent, 0);
        }
        if(position == 2)
        {

                 Intent myIntent =  new Intent(soru.this, geo.class);
                     startActivityForResult(myIntent, 0);
        }
        if(position == 3)
        {

                 Intent myIntent =  new Intent(soru.this, fizik.class);
          startActivityForResult(myIntent, 0);
        }
                     if(position == 4)
                    {

                   Intent myIntent =  new Intent(soru.this, kimya.class);
            startActivityForResult(myIntent, 0);
                    }
                     if(position == 5)
                        {

                       Intent myIntent =  new Intent(soru.this, biyoloji.class);
                startActivityForResult(myIntent, 0);
                        }
                     if(position == 6)
                        {

                       Intent myIntent =  new Intent(soru.this, edebiyat.class);
                startActivityForResult(myIntent, 0);
                        }
                     if(position == 7)
                        {

                       Intent myIntent =  new Intent(soru.this, espanol.class);
                startActivityForResult(myIntent, 0);
                        }    

            }
          });
        }

}

Upvotes: 0

Views: 79

Answers (1)

Antrromet
Antrromet

Reputation: 15414

I think the best solution for you is to use the ExpandableListView. A very simple to use tutorial on how to implement is given here.

Upvotes: 2

Related Questions