Iconified TextList - The making of

Basic Tutorials concerning: GUI, Views, Activites, XML, Layouts, Intents, ...

Postby Mazinkaiser » Sun Jan 10, 2010 6:57 pm

sorry guys, exactly how can i make the list clickable? the common setOnClickListener dosen't work for me...
Mazinkaiser
Freshman
Freshman
 
Posts: 9
Joined: Fri Oct 16, 2009 12:21 pm

Top

Postby YaW » Thu Feb 25, 2010 9:33 am

Hi plusminus.

I followed your tutorial and it works great! Nice job.

I have a question. It's possible to make one onClickListener on the image and other different onClickListener on the text?

Greetings
Sorry for my poor English.
User avatar
YaW
Junior Developer
Junior Developer
 
Posts: 16
Joined: Thu Feb 25, 2010 8:54 am

Postby yeochinh » Tue Mar 16, 2010 4:04 pm

Thanks for the awesome tutorial!
I'd like to ask if you can make a continuation tutorial on how I make the list clickable (say for example, i clicked on Learn spanish) and then be able to forward it to the next form. (say I have another set of list on the other form specifically for the "Learn SPanish" entry).
Thanks very much for your time!

(sorry, im just a novice in creating android apps)
yeochinh
Once Poster
Once Poster
 
Posts: 1
Joined: Tue Mar 16, 2010 7:07 am

Postby korakrit » Tue Mar 30, 2010 6:58 pm

thank for sharing please post XML Layout
korakrit
Freshman
Freshman
 
Posts: 2
Joined: Tue Nov 03, 2009 2:46 pm

Postby vik » Wed Mar 31, 2010 11:22 am

hey all ...
I am using this tutorial and everything is working fine.
Now i am downloading images from the URL to be shown in this view Using "aSync".
so i will have to get all the instances of imageView ; so for that i am storing in array of imageview
but now what is happening is that suppose i am at record 1 and image have been downloaded for record 5 but only 1-4 are currently shown in lisview then it throws null pointer exception .

i know even why it is thrown ; it is because imageview of record 5 havent been created yet till we scroll to recod 5.
now how to solve this problem?
User avatar
vik
Senior Developer
Senior Developer
 
Posts: 141
Joined: Wed Sep 09, 2009 7:32 am

Re: Iconified TextList - The making of

Postby shre » Wed May 19, 2010 4:55 am

hi..

am new to android development.. please someone help me.. i tried to run this code.. dut as soon as i click on run, message is displayinf like this "your project contains error(s), please fix them before running" .. but there is no error in code.. please help me :(
shre
Once Poster
Once Poster
 
Posts: 1
Joined: Tue May 18, 2010 1:33 pm

Top

Re: Iconified TextList - The making of

Postby limteckchai » Mon Jun 28, 2010 9:33 am

Hey All,
Thanks for the great tutorial.

Firstly, I have followed Anddev's several tutorials like this 1 and tab, and some others mashing them up to get a cool app.
Thanks to this tutorial, i managed to upgrade my Listview to have icons on them and somehow it does not allow me to implement onClickListener() or onItemClickListener().The codes i use are almost exactly the same as the one from the tutorial.

An extract of the code
Code: Select all
IconifiedTextListAdapter itla = new IconifiedTextListAdapter(this);
   
      itla.addItem(new IconifiedText("Bakeries", getResources().getDrawable(
            R.drawable.makan_bakeries)));
      itla.addItem(new IconifiedText("Bars & Wines", getResources()
            .getDrawable(R.drawable.makan_barswines)));

setListAdapter(itla);


The code works and shows the icon of a bakery next to the word Bakeries, but i dun noe how to make the app react to ~clicks~. :oops:

Thanks in advance!! Cheers :D
limteckchai
Experienced Developer
Experienced Developer
 
Posts: 92
Joined: Mon Jun 28, 2010 3:33 am

Re: Iconified TextList - The making of

Postby spring » Mon Aug 16, 2010 6:47 am

great code for me,thanks for you sharing
spring
Junior Developer
Junior Developer
 
Posts: 19
Joined: Sat Jan 09, 2010 4:37 am
Location: China

Re: Iconified TextList - The making of

Postby zeroARM000 » Tue Apr 12, 2011 3:25 pm

how to get a list item position by clicking the button inside it?

Hi guys, actually I've read some previous questions about this...

this is the code that I use
Code: Select all
auto = (ListView)findViewById(R.id.auto);
String[] projection = new String[] {Browser.BookmarkColumns._ID,Browser.BookmarkColumns.TITLE,Browser.BookmarkColumns.URL};

    String[] displayFields = new String[] {Browser.BookmarkColumns.TITLE, Browser.BookmarkColumns.URL};

    int[] displayViews = new int[] { R.id.text1,R.id.text2 };

    Cursor cur = managedQuery(android.provider.Browser.BOOKMARKS_URI,projection, null, null, null);

    //auto.setAdapter(new SimpleCursorAdapter(this, R.layout.mylist, cur,displayFields, displayViews));

    myAdapter apt = new myAdapter(this, R.layout.mylist, cur,displayFields, displayViews);
    auto.setAdapter(apt);


and class myAdapter
Code: Select all
class myAdapter extends SimpleCursorAdapter{

    private Cursor c;
    private Context context;


    public myAdapter(Context context, int layout, Cursor c, String[] from,
            int[] to) {
        super(context, layout, c, from, to);
        // TODO Auto-generated constructor stub
        this.c = c;
        this.context = context;
        AutoList att = new AutoList();
        mListView = att.auto;

    }

    @Override
    public View getView(int pos, View inView, ViewGroup parent) {
           View vix = inView;

           if (vix == null) {
                LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                vix = inflater.inflate(R.layout.mylist, null);
           }
           this.c.moveToPosition(pos);     

           String title = this.c.getString(this.c.getColumnIndex(Browser.BookmarkColumns.TITLE));

           String cont = this.c.getString(this.c.getColumnIndex(Browser.BookmarkColumns.URL));

               TextView text1 = (TextView) vix.findViewById(R.id.text1);
               text1.setText(title);
               TextView text2 = (TextView) vix.findViewById(R.id.text2);
               text2.setText(cont);
               Button butt = (Button) vix.findViewById(R.id.button);
               butt.setOnClickListener(mButt);
               return vix;
    }

    private OnClickListener mButt = new OnClickListener() {
        @Override
        public void onClick(View v) {
        final int position = mListView.getPositionForView((View) v.getParent());
            Log.v("BUTT", "Title clicked, row "+position);
        }
    };


However, when I click the button, I still get a lot of errors like this:
Code: Select all
04-10 22:30:55.152: ERROR/AndroidRuntime(695): FATAL EXCEPTION: main
04-10 22:30:55.152: ERROR/AndroidRuntime(695): java.lang.NullPointerException
04-10 22:30:55.152: ERROR/AndroidRuntime(695):     at             com.auto2.AutoList$myAdapter$1.onClick(AutoList.java:113)
04-10 22:30:55.152: ERROR/AndroidRuntime(695):     at   android.view.View.performClick(View.java:2408)
04-10 22:30:55.152: ERROR/AndroidRuntime(695):     at   android.view.View$PerformClick.run(View.java:8816)
04-10 22:30:55.152: ERROR/AndroidRuntime(695):     at android.os.Handler.handleCallback(Handler.java:587)
04-10 22:30:55.152: ERROR/AndroidRuntime(695):     at   android.os.Handler.dispatchMessage(Handler.java:92)
04-10 22:30:55.152: ERROR/AndroidRuntime(695):     at android.os.Looper.loop(Looper.java:123)
04-10 22:30:55.152: ERROR/AndroidRuntime(695):     at android.app.ActivityThread.main(ActivityThread.java:4627)
04-10 22:30:55.152: ERROR/AndroidRuntime(695):     at java.lang.reflect.Method.invokeNative(Native Method)
04-10 22:30:55.152: ERROR/AndroidRuntime(695):     at java.lang.reflect.Method.invoke(Method.java:521)
04-10 22:30:55.152: ERROR/AndroidRuntime(695):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-10 22:30:55.152: ERROR/AndroidRuntime(695):     at   com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-10 22:30:55.152: ERROR/AndroidRuntime(695):     at   dalvik.system.NativeStart.main(Native Method)


That's it! I hope it won't be so difficult to be figured out!

Thanks!
zeroARM000
Freshman
Freshman
 
Posts: 5
Joined: Tue Apr 05, 2011 10:01 am

Top
Previous

Return to Novice Tutorials

Who is online

Users browsing this forum: No registered users and 4 guests