Iconified TextList - The making of

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

Postby qamerfarooq » Wed Jan 16, 2008 6:20 am

adnan1146 wrote:
plusminus wrote:Hey lordhong,

Nice upgrade =)

You could try to loop through all Views at the end of the onCreate()-method and invalidate(); them. Like:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. // <img src="http://www.anddev.org/images/smilies/icon_exclaim.gif" alt=":!:" title="Exclamation" /> Brain to Code - NOT TESTED <img src="http://www.anddev.org/images/smilies/icon_exclaim.gif" alt=":!:" title="Exclamation" />
  2. public void onCreate(Bundle icicle) {
  3.         super.onCreate(icicle);
  4.         ImageItemArrayAdapter adapter = new ImageItemArrayAdapter(this);
  5.         Resources res = this.getResources();
  6.         // add one items
  7.         adapter.addItem(new ImageItem("Home", res.getDrawable(R.drawable.sliderhouse), true));
  8.         // add some more items...
  9.         // ...
  10.         setListAdapter(adapter);
  11.        
  12.         for(int i = 0; i < adapter.getCount(); i++){
  13.                 adapter.getView(i, null, null).invalidate();
  14.         }
  15. }
Parsed in 0.032 seconds, using GeSHi 1.0.8.4

Let us know if it worked.

I'll have a closer look at it, when I'm back home from university.

Regards,
plusminus


Hi plusminus

I have also modified the iconified list to have few checkboxes,text views and imagesviews, but I am facing the similar problem of list refresh after performing some action. If you could help in this regard, and write some code to refresh the list.

I also tried the code you written before using invalidate();



I also modified the iconified list which has few checkboxes loading their state( checked/unchecked) from a database and its working fine with refresh after any update etc..

I am able to refresh the list after some update by sending another query to the data base and setting the list adapter with the new data.
qamerfarooq
Junior Developer
Junior Developer
 
Posts: 13
Joined: Fri Jan 11, 2008 6:07 am
Location: Pakistan

Top

Want to place the icon image at the right side of the screen

Postby Preet » Tue Jan 22, 2008 10:28 am

Hi
I m working with the images and want to place at the end of the screen
i.e. right aligned
that means at left i write the text and at right i want my image to be
displayed.
but as
mIcon.setPadding(190 , 0, 0, 0); function does not work it place the
images relative to what i dont know.

Plz solve my problem.
Preet
Once Poster
Once Poster
 
Posts: 1
Joined: Tue Jan 22, 2008 6:17 am

Re: Want to place the icon image at the right side of the sc

Postby qamerfarooq » Thu Jan 24, 2008 6:56 am

Preet wrote:Hi
I m working with the images and want to place at the end of the screen
i.e. right aligned
that means at left i write the text and at right i want my image to be
displayed.
but as
mIcon.setPadding(190 , 0, 0, 0); function does not work it place the
images relative to what i dont know.

Plz solve my problem.


Add the Text component using the following code:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. TextView name = new TextView(context);
  2. addView(name, new LinearLayout.LayoutParams(
  3.               LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1));
  4.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


Actually we have to set the text component's weight to 1.
Qamer Farooq
End 2 End Solution Providers
http://www.e2esp.com
qamerfarooq
Junior Developer
Junior Developer
 
Posts: 13
Joined: Fri Jan 11, 2008 6:07 am
Location: Pakistan

Postby cabernet1976 » Fri Jan 25, 2008 6:59 pm

Can we change the height of the line in the icon list view? It seem too narrow.
Thanks.
Upload2Flickr's blog: http://upload2flickr.blogspot.com
cabernet1976
Senior Developer
Senior Developer
 
Posts: 154
Joined: Fri Nov 16, 2007 2:34 am
Location: China

Postby Cybermat » Sun Jan 27, 2008 2:56 am

You can try padding the icon list view to match that of the text view.
Use the iconview.setPadding(left, top, right, bottom) function.

Cheers
Cybermat
Junior Developer
Junior Developer
 
Posts: 11
Joined: Mon Dec 03, 2007 5:42 am

Postby cabernet1976 » Mon Jan 28, 2008 4:33 am

Thanks, Cybermat,
I will try and tell you the result.
Upload2Flickr's blog: http://upload2flickr.blogspot.com
cabernet1976
Senior Developer
Senior Developer
 
Posts: 154
Joined: Fri Nov 16, 2007 2:34 am
Location: China

Top

Postby cabernet1976 » Mon Jan 28, 2008 7:01 pm

Hi Cybermat,
It works fine.
Thank you again.
Upload2Flickr's blog: http://upload2flickr.blogspot.com
cabernet1976
Senior Developer
Senior Developer
 
Posts: 154
Joined: Fri Nov 16, 2007 2:34 am
Location: China

Where i can found main.xml for Iconified list Example

Postby gvkreddyvamsi » Mon Feb 04, 2008 10:02 am

HI,

Done well.

But getting error in R.java. Some attributes missing.

Please post main.xml

by
vamsi
gvkreddyvamsi
Developer
Developer
 
Posts: 43
Joined: Mon Jan 21, 2008 5:10 am
Location: INDIA

Re: Where i can found main.xml for Iconified list Examp

Postby plusminus » Mon Feb 04, 2008 10:41 am

Hello gvkreddyvamsi,
gvkreddyvamsi wrote:But getting error in R.java. Some attributes missing.

these are very probably just the drawables, right :?:
Choose any image you want and drop it into the /res/drawable/-Folder in Eclipse then alter the R.drawable.xyz-lines in the javacode to the new images.

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Thank you very much ...

Postby gvkreddyvamsi » Mon Feb 04, 2008 10:52 am

Hi,

Thank you.

by
vam
gvkreddyvamsi
Developer
Developer
 
Posts: 43
Joined: Mon Jan 21, 2008 5:10 am
Location: INDIA

Postby bluefloyd8 » Sat Feb 09, 2008 12:50 am

Do I need to modify IconifiedTestListAdapter if I want to extend how keys effect the list? For example, I want to have hitting ENTER (center key) to select the the item in the list. I do this by overloading onListItemClick in my ListActivity. I would like to add the ability to call a different function or activity when pressing the RIGHT D-PAD KEY instead of the ENTER key.

onListItemRightClick(....

or

onListItemClick(int KEYCODE, ...
User avatar
bluefloyd8
Experienced Developer
Experienced Developer
 
Posts: 70
Joined: Tue Jan 22, 2008 3:57 am
Location: Indiana, USA

Postby plusminus » Sat Feb 09, 2008 11:28 am

Hello bluefloyd,

You are thinking of this :darrow: :?:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.         @Override
  2.  
  3.         public boolean onKeyDown(int keyCode, KeyEvent event) {
  4.  
  5.                 // TODO Auto-generated method stub
  6.  
  7.                 return super.onKeyDown(keyCode, event);
  8.  
  9.         }
Parsed in 0.034 seconds, using GeSHi 1.0.8.4


Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby Jesmiatka » Wed Feb 13, 2008 4:09 pm

Tsup guys!

I made my own list but now I wanted to add a layout like is done with this:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. listView.setAdapter(new ArrayAdapter<String>(this,
  2.  
  3. android.R.layout.simple_list_item_1_small,
  4.  
  5. items));
Parsed in 0.035 seconds, using GeSHi 1.0.8.4


But it's late and my brain is numb so at the moment I'm not finding the solution that quick ;-) Anyone have the solution by hand ? :P

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.                 IssueListAdapter ila = new IssueListAdapter(this);
  2.  
  3.                 ila.addItem(new IssueItem("1", "2"));
  4.  
  5.                 ila.addItem(new IssueItem("3", "4"));
  6.  
  7.                 ila.addItem(new IssueItem("5", "6"));
  8.  
  9.                 ListView lv = (ListView) findViewById(R.id.lv_atm);
  10.  
  11.                 lv.setAdapter(ila);
Parsed in 0.037 seconds, using GeSHi 1.0.8.4
Jesmiatka
Senior Developer
Senior Developer
 
Posts: 164
Joined: Mon Feb 04, 2008 3:37 pm
Location: Netherlands

Postby manmath » Fri Feb 15, 2008 2:01 pm

This is a Very useful tutorial.
Can we modify the design as shown below ?

IconifiedTextListAdapter itla= new IconifiedTextListAdapter(Context, <row layout.xml>, <drawable array>, <String array>)
setListAdapter(itla);

I guess this is the standard way Arrayadapter is used.
While implementing the above design, i am not able to create a layout out of rowlayout.xml in the file IconifiedTextView.java..
Which API can be used to get the layout object out of .xml?
Can anybody suggest the solution for this type of implementation ?



Thanks in advance
manmath
Junior Developer
Junior Developer
 
Posts: 18
Joined: Fri Feb 15, 2008 1:30 pm
Location: India

beside image view can a list have a list inside(small one)

Postby rahul_mawkins » Wed Feb 27, 2008 9:03 am

I have a category list. I want when user clicks on any category the listItem should expand and shows the subcategory in a inner List
So like you used added an ImageView can we add a ListView
like image view we can say

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. addView(innerListView....some layout params)
Parsed in 0.035 seconds, using GeSHi 1.0.8.4


But the problem is supplying data to this innerListView because even though we make

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. private class InnerListView extends  ListView
  2.  
  3. {
  4.  
  5.  
  6.  
  7.    public InnerListView(Context ct)
  8.  
  9.   {
  10.  
  11.        setAdapter(new InnerListViewAdapter(ct);//THIS IS THERE BUT IT DOES NOTHING
  12.  
  13.        // IF WE ADD AS LISTADAPTER THEN IT GOES ALL THE WAY UP SETTING THE WHOLE
  14.  
  15.       //ADAPTER OF PRIMARY LIST AS THIS
  16.  
  17.   }
  18.  
  19.  
  20.  
  21. private class InnerListViewAdapter extends BaseAdapter implements ListAdapter
  22.  
  23. {
  24.  
  25. ......overidden methods
  26.  
  27. }
Parsed in 0.037 seconds, using GeSHi 1.0.8.4


But there is no method

there is no method in ListView class which can add ListAdapter as shown above

So how do we supply data to ListView using our own adapter which implements ListAdapter

Hope I am able to make you folks understand what I am trying to do....A LIST INSIDE A LIST
rahul_mawkins
Developer
Developer
 
Posts: 34
Joined: Wed Feb 27, 2008 4:09 am

Top
PreviousNext

Return to Novice Tutorials

Who is online

Users browsing this forum: No registered users and 3 guests