Android: onListItemClick in Activity

前端 未结 8 1981
故里飘歌
故里飘歌 2020-12-28 21:23

Previous time I asked a question here I learned a lot so I guess it\'s worth a shot to try it again.

I am using the lazy list by Fedor from this link: Lazy load of i

8条回答
  •  醉梦人生
    2020-12-28 21:36

    I have been working on this all day and after making my own ArrayAdapter I couldn't figure out how to change classes in my list.

    Here's how I found out how to do it. After I called my array i simply finished out my code in that method by doing.

    ListView lv =getListView();
    lv.setOnItemClickListener(this);
    

    Then after all my text i put

    public void onItemClick(AdapterView arg0, View arg1, int position,
                long arg3) {
        String item = (String) getListAdapter().getItem(position);
    
        if (item.equals("Economy"))
        {
            Intent intent = new Intent(packages.this, economy.class);
            startActivity(intent);
        }
        else if (item.equals("Basic"))
        {
            Intent intent = new Intent(packages.this, basic.class);
            startActivity(intent);
        }
        else if (item.equals("Professional"))
        {
            Intent intent = new Intent(packages.this, professional.class);
            startActivity(intent);
        }
        else if (item.equals("Custom Applications"))
        {
            Intent intent = new Intent(packages.this, applications.class);
            startActivity(intent);
        }
    }
    

    Between I managed to completely customize my ListView with custom font and backgrounds. I'm sure a ton of you don't really care. But I'm exited and was hoping by posting this that I might help someone in the future.

提交回复
热议问题