• 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

Put a Linear Layout

 
Ranch Hand
Posts: 283
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have created in my file .xml a linear layout
I want to create in this linear layout a linear layout which contains 3 linear layout with this latter contains a button and a text view below
I create a method but it does not display anything:
here's the method :
 
Sarra Sakka
Ranch Hand
Posts: 283
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I waant to put all this in Scroll View
 
Sarra Sakka
Ranch Hand
Posts: 283
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to show the image to explain better, but i don't know how can put it here
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you use the "Post Reply" button, then you can add images via the "Attachments" tab.
 
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
I suspect you are trying to do what a ListView already does. See the developers network article on ListViews. What I would suggest doing is create one Layout for just the inner most LinearLayout (I call this text_and_btton.xml):


Then you define the outer layout with a ListView:

Then you make an adapter that basically is a list of the text and images you want to put into the ListView. The adapter creates the 'inner most' of you layouts - the one with the button and text. Here is an example:


Then in the activity where you want to display the list, you build the layout with the list view, then get the ListView and set the adapter:


If you link this with your other posts, the ImageStuffAdapter is the correct place to do the database work to get the images and text you want to display.
 
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
Below is an example of the output from running the above code.

When you do this, you could just as easily make the Buttons ImageViews. You do not need the Button's onClick event because you would use the ListView's onItemClick event to get which item (index) was clicked on.
Sample-ListView.png
[Thumbnail for Sample-ListView.png]
output from above code
 
Sarra Sakka
Ranch Hand
Posts: 283
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot steve
I want to put here the image that's i made with the photoshop to explain to you what i want exactly
how can i put it !!
 
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
My code compiles and runs as written. What part aren't you able to do?
 
Sarra Sakka
Ranch Hand
Posts: 283
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to show you an image to explain to explain to you what i want exactly
i don't know how can i put an image here in this forum
 
Sarra Sakka
Ranch Hand
Posts: 283
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks a lot steve
 
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

Sarra Sakka wrote:I want to show you an image to explain to explain to you what i want exactly
i don't know how can i put an image here in this forum



Ulf Dittmer wrote:If you use the "Post Reply" button, then you can add images via the "Attachments" tab.

 
Sarra Sakka
Ranch Hand
Posts: 283
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
here's the image that i want
Sans-titre.png
[Thumbnail for Sans-titre.png]
 
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
Ah, then you want a GridView instead of a ListView: http://developer.android.com/guide/topics/ui/layout/gridview.html

Pretty similar stuff to the last code. The new outermost layout uses a GridView instead of a ListView. Not it has a few options for defining the width of a column and number of columns:


And the activity has to change to use the GridView instead of ListView:

Note I also set a background... but that is for show Nothing else changes, and the output is shown below.
Sample-GridView_landscape.png
[Thumbnail for Sample-GridView_landscape.png]
Sample-GridView_lportrait.png
[Thumbnail for Sample-GridView_lportrait.png]
 
Sarra Sakka
Ranch Hand
Posts: 283
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeees , that's it
thank you Steve
 
Sarra Sakka
Ranch Hand
Posts: 283
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you please correct my method
 
Sarra Sakka
Ranch Hand
Posts: 283
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What's the bkg ??

 
Sarra Sakka
Ranch Hand
Posts: 283
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It work now ,wow !!
I change my code and every thing is ok ;)

 
Sarra Sakka
Ranch Hand
Posts: 283
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to get this gird view when i pressed a button !!
how can i do it !
 
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

Sarra Sakka wrote:I want to get this gird view when i pressed a button !!
how can i do it !


Not sure I understand the question. Are you asking about app navigation via buttons?
 
Sarra Sakka
Ranch Hand
Posts: 283
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you see this https://coderanch.com/t/615919/Android/Mobile/put-dynamically-Imagebutton
I put another question Steve
 
Sarra Sakka
Ranch Hand
Posts: 283
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Steve, I want to know if there is a method that allows you to erase the contents of a linear layout
 
Sarra Sakka
Ranch Hand
Posts: 283
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I need your help !!
 
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

Sarra Sakka wrote:I need your help !!


Possibly. But this is an all-volunteer forum, and demanding attention using exclamation marks isn't going to make people want to help you. Also, bumping posts repeatedly within the space of hours is considered bad behavior. PatienceIsAVirtue, as I've mentioned before. And you still don't seem to grasp that people sometimes sleep, and even when they're not, they might have better things to do than jump to your assistance.
 
Sarra Sakka
Ranch Hand
Posts: 283
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, i'm sorry
 
I guess I've been abducted by space aliens. So unprofessional. They tried to probe me with 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