• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

how to add main two button to my screen

 
Ranch Hand
Posts: 1325
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:
 
shawn peter
Ranch Hand
Posts: 1325
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
shawn peter
Ranch Hand
Posts: 1325
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
shawn peter
Ranch Hand
Posts: 1325
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
shawn peter
Ranch Hand
Posts: 1325
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
shawn peter
Ranch Hand
Posts: 1325
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
I love a good mentalist. And so does this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic