wood burning stoves 2.0*
The moose likes Android and the fly likes Put a Linear Layout Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "Put a Linear Layout" Watch "Put a Linear Layout" New topic
Author

Put a Linear Layout

Sarra Sakka
Ranch Hand

Joined: Jul 12, 2013
Posts: 274
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

Joined: Jul 12, 2013
Posts: 274
I waant to put all this in Scroll View
Sarra Sakka
Ranch Hand

Joined: Jul 12, 2013
Posts: 274
I want to show the image to explain better, but i don't know how can put it here
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42915
    
  68
If you use the "Post Reply" button, then you can add images via the "Attachments" tab.
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

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
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

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.



[Thumbnail for Sample ListView.png]

Sarra Sakka
Ranch Hand

Joined: Jul 12, 2013
Posts: 274
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

Joined: Jan 28, 2003
Posts: 4181
    
  21

My code compiles and runs as written. What part aren't you able to do?
Sarra Sakka
Ranch Hand

Joined: Jul 12, 2013
Posts: 274
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

Joined: Jul 12, 2013
Posts: 274
thanks a lot steve
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

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

Joined: Jul 12, 2013
Posts: 274
here's the image that i want


[Sans titre.png]

Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

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.


[Thumbnail for Sample GridView_landscape.png]

[Thumbnail for Sample GridView_lportrait.png]

Sarra Sakka
Ranch Hand

Joined: Jul 12, 2013
Posts: 274
Yeees , that's it
thank you Steve
Sarra Sakka
Ranch Hand

Joined: Jul 12, 2013
Posts: 274
Can you please correct my method
Sarra Sakka
Ranch Hand

Joined: Jul 12, 2013
Posts: 274
What's the bkg ??

Sarra Sakka
Ranch Hand

Joined: Jul 12, 2013
Posts: 274
It work now ,wow !!
I change my code and every thing is ok ;)

Sarra Sakka
Ranch Hand

Joined: Jul 12, 2013
Posts: 274
I want to get this gird view when i pressed a button !!
how can i do it !
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

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

Joined: Jul 12, 2013
Posts: 274
Can you see this http://www.coderanch.com/t/615919/Android/Mobile/put-dynamically-Imagebutton
I put another question Steve
Sarra Sakka
Ranch Hand

Joined: Jul 12, 2013
Posts: 274
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

Joined: Jul 12, 2013
Posts: 274
I need your help !!
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42915
    
  68
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

Joined: Jul 12, 2013
Posts: 274
Ok, i'm sorry
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Put a Linear Layout