wood burning stoves 2.0*
The moose likes Android and the fly likes how to add main two button to my screen Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Android
Bookmark "how to add main two button to my screen" Watch "how to add main two button to my screen" New topic
Author

how to add main two button to my screen

sam liyanage
Ranch Hand

Joined: Nov 25, 2008
Posts: 1087
below is my main xml




I am using list view.below is the part of adapter.


I need to add two main buttons to the above list view.can anyone tell me the way to add.I try to add to the xml.then it gives me two butons for each list view item.please help.
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

You don't add the buttons to the layout for the items in the ListView, you add the ListView to a layout which has the buttons:


Steve
sam liyanage
Ranch Hand

Joined: Nov 25, 2008
Posts: 1087
this is my list_mobile.xml file.


it have both image and textview.

below is the adapter class


its working fine.I just need to add two buttons to the top of the screen.when i add buttons to list_mobile it adds buttons for each rows.please help me.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41621
    
  55
Reread and consider this statement:
Steve Luke wrote:You don't add the buttons to the layout for the items in the ListView, you add the ListView to a layout which has the buttons:

It's spot on; what do you think it means?


Ping & DNS - my free Android networking tools app
sam liyanage
Ranch Hand

Joined: Nov 25, 2008
Posts: 1087
tnx Steve and Dittmer.anyway i don't understand what you are saying.can you anyone please explain more.i mean with an example.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41621
    
  55
There's a disconnect somewhere between your posts. If the layout XML file you posted is indeed your main XML layout, then adding button to it can't possibly result in multiple double buttons appearing in the layout, because the list view does not use that layout. From your code it's clear that it uses a layout called "list_mobile". So - what happened when you added two buttons to your main XML layout file?

Also, my first name is "Ulf". If you want to address me by my last name then the polite way to do so is to say "Mr. Dittmer". First name's fine, though, like you did with Steve. I already pointed that out here; please do so from now on.
sam liyanage
Ranch Hand

Joined: Nov 25, 2008
Posts: 1087
Tnx Ulf. Sorry for inconvenience occurred.
above mentioned list_mobile is the xml file which use adapter to show list.So if i put buttons on it,it gives me buttons for each list items.I don't want it.I just need two buttons in top.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41621
    
  55
So you have a layout, and you need two buttons on it. Apparently you know how to add buttons to a layout, since you have done so with the list_mobile layout. What prevents you from doing the same with the main layout?
sam liyanage
Ranch Hand

Joined: Nov 25, 2008
Posts: 1087
actually my main xml is not showing.It's not using.When apps starts it automatically goes to the list view.So my main xml is not using inapp.So i have to add buttons to the my list_mobile xml.is there a way to add them to it without repeating ?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41621
    
  55
When apps starts it automatically goes to the list view.

I doubt that. Something is telling the app which layout to use. Since we haven't seen your main Activity code, we don't know how that works. But anything involving the list view is not the answer.
sam liyanage
Ranch Hand

Joined: Nov 25, 2008
Posts: 1087
actually i dihe the main.xml file as below.because i don't need to show anything in first activity.It checks wich Activity to select within that.So based on the network providers type it select the activity.So no need o show anything.when the app runs it autumatically goes to 2nd activity.that's really happens.

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41621
    
  55
OK, so it's not the main activity, but some other activity that shows the GUI. But that makes no difference - somehow it sets the layout, and that's where you need to show a layout that contains what you want it to contain (along the lines of what Steve suggested).
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

Put it a different way. Pretend your ListView was some other type of view, say a TextView. How would you makea layout that showed the TextView and two buttons?

Now change the TextView to a ListView.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: how to add main two button to my screen