[Logo]
Forums Register Login
Put a Linear Layout
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 :
I waant to put all this in Scroll View
I want to show the image to explain better, but i don't know how can put it here
If you use the "Post Reply" button, then you can add images via the "Attachments" tab.
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.
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
output from above code
[Thumbnail for Sample-ListView.png]
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 !!
My code compiles and runs as written. What part aren't you able to do?
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
thanks a lot steve
 

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.

 
here's the image that i want
Sans-titre.png
[Sans-titre.png]
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]
Yeees , that's it
thank you Steve
Can you please correct my method
What's the bkg ??

It work now ,wow !!
I change my code and every thing is ok ;)

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

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?
Can you see this http://www.coderanch.com/t/615919/Android/Mobile/put-dynamically-Imagebutton
I put another question Steve
Steve, I want to know if there is a method that allows you to erase the contents of a linear layout
I need your help !!
 

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.
Ok, i'm sorry
It's weird that we cook bacon and bake cookies. Eat this tiny ad:
Why should you try IntelliJ IDEA ?
https://coderanch.com/wiki/696337/IntelliJ-IDEA


This thread has been viewed 1372 times.

All times above are in ranch (not your local) time.
The current ranch time is
Aug 18, 2018 22:33:20.