Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

can't we add two chicld elements to HorizontalScrollView

 
sam liya
Ranch Hand
Posts: 1243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1)I neded to add a list view with horizontal scrollview.here is the example i used.it's working fine.anyway if i add two linearlayouts it gives error



2)can we use list view inside HorizontalScrollView?
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sameera liyanage wrote:1)I neded to add a list view with horizontal scrollview.here is the example i used.it's working fine.anyway if i add two linearlayouts it gives error

From the API:
A HorizontalScrollView is a FrameLayout, meaning you should place one child in it containing the entire contents to scroll; this child may itself be a layout manager with a complex hierarchy of objects.

sameera liyanage wrote:2)can we use list view inside HorizontalScrollView?

Yes. Make sure the two (scroll and list) scroll in different directions, otherwise it gets confusing as to which is moving. Also, to see the horizontal scroll view, you will need to make the elements in the list view wider than the screen.

My guess is you want something else. Can you explain exactly what you want to do?
 
sam liya
Ranch Hand
Posts: 1243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to show data with colums and rows.there are several columns and several rows.So my screen is not enough for to show all this data .So i need to have horizontal scroll view.anyway below is my list view without scrollview.

main.xml


main activity

 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sameera liyanage wrote:I need to show data with colums and rows.there are several columns and several rows.So my screen is not enough for to show all this data

You need columns and you need rows? Sounds like you need a GridView.

See:
http://developer.android.com/guide/topics/ui/layout/gridview.html
http://developer.android.com/reference/android/widget/GridView.html
 
sam liya
Ranch Hand
Posts: 1243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
anyway i have 7 colums and 18 rows exacly.Also i have header column.can i use gridview to archive this.I mean if i use gridview can i archive scrollview also.because ithere are 7 colums and 18 rows it doesn't show all data in one screnn.
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you looked at the resources I gave?
 
sam liya
Ranch Hand
Posts: 1243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1)yes Steve i checked.Anyway can we limit the number of columns and rows in gridview.I mean can we define how many columns and rows to show ?

2)anyway i use table layout as below.now i can scroll both sides.but i use textViews.can i use listView for below?

 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sameera liyanage wrote:1)yes Steve i checked.Anyway can we limit the number of columns and rows in gridview.I mean can we define how many columns and rows to show ?

The documentation and the guide both give you the answer to that question.

sameera liyanage wrote:2)anyway i use table layout as below.now i can scroll both sides.but i use textViews.can i use listView for below?

The API for ListView is here: http://developer.android.com/reference/android/widget/ListView.html
The first sentence in the description gives you the answer.
 
sam liya
Ranch Hand
Posts: 1243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
now it seems fine.see the code bwlow.

main.xml



main activity
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic