Simple non interactive ListView Android - android

Please cope with me as im new to android and i have done a lot of searching on my own, about this, and im fed up not finding a proper way.
This is my custom listview template. rowbuttonlayout.xml.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#+id/label"
android:textSize="19.6dp" >
</TextView>
<CheckBox
android:id="#+id/check"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginLeft="3.6dp"
android:layout_marginRight="9.6dp" >
</CheckBox>
<TextView
android:id="#+id/result"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/check"
android:layout_alignBottom="#+id/check"
android:layout_toLeftOf="#+id/check"
android:text="#string/nothing" />
</RelativeLayout>
What i want is to create something like this in this pic without the header and footer.
http://www.vogella.com/articles/AndroidListView/images/xinteractive10.png.pagespeed.ic.V0cVgp99SN.png
As on my layout ill be having another textview just before the checkbox as well. Also ill be adding a dynamic button at the footer.
Now i dont want the users to interact with my listview. Only the button should be clickable and when they click it i want to run some calculations and show them in the relevant "result" textview and to check the checkbox next to it to show that i have calculated it. Meaning i have to access each and every "result" textview and "check" checkbox in the code.
Please provide me some guidance for coding this app. Im fed up looking through very complex codes trying learn on my own. Many many thanks for your help.
Shavinka

Check out below links...
ListView + CheckBox =?
How to get checked items from android listview?
http://sunil-android.blogspot.in/2013/04/android-listview-checkbox-example.html
http://fundoocode.net/android-listview-checkbox-example-onitemclicklistener-and-onclicklistener/
http://www.mysamplecode.com/2012/07/android-listview-checkbox-example.html

Related

RecyclerView shows the borderd textview only after scrolling

I have an arrayList of books. It contains the book name and book tags (say history, novel, story etc.). I have used RecyclerView for listing. It works fine but the problem is that here tags are showing like text in the box.
Sometimes tags are not showing at the initial loading. after scrolling tags get displayed.
I don't know whats happening in the code. I think the issue is with the RecyclerView. I am setting thet visibility to VISIBLE in onBindViewHolder still didnt get.
here is my xml
<LinearLayout
android:layout_width="220dp"
android:layout_height="wrap_content"
android:id="#+id/tag_layout"
android:layout_marginTop="2dp"
android:layout_alignLeft="#+id/story_name"
android:layout_below="#id/story_name">
<TextView
android:id="#+id/tag1"
android:layout_width="wrap_content"
android:layout_height="20dp"
android:textSize="12dp"
android:paddingLeft="6dp"
android:paddingRight="11dp"
android:paddingBottom="3.5dp"
android:background="#drawable/roundedcorner"/>
</LinearLayout>
onBindViewHolder
holder.tag1.setText("tag name ");
holder.tag1.setVisibility(View.VISIBLE);

How do you create a 'read more' layout in Android?

I want to display a 'read more' link when the obtained text increases to a certain limit, so that if user wants to read in detail, they can click on read more just like the Application installation page of Play Store
Please suggest me on how to implement this
You can refer this. Layout available on git hub
https://github.com/traex/ExpandableLayout
Thank you all for giving answer, here is how i solved it.
There is a property called android:maxLines=""
using this property we can add Read More text view below the text view by making it clickable so that when user clicks on the text view we can perform any action we wanted
Example:
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Device supports NFS etc....."
android:maxLines="4"
android:id="#+id/description" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Read More"
android:layout_gravity="center_horizontal"
android:textColor="#0066FF"
android:id="#+id/readmore" />
I hope this helps.
Look like on google play this link opens other activity. So, it is just button with startActivity() behavior.

Listview item background image problem in my android application

I have in my application a listview with an adapter that uses different layouts for the items.
I want the result to be like in the attached exp_result.png.
http://imageshack.us/photo/my-images/717/expresult.png/
But unfortunatly - I get like in result.png.
http://imageshack.us/photo/my-images/839/resultf.png/
The problem is that image stretches on the screen not the way I wanted.
Any ideas?
Maybe other solution to this layout - maybe built in?
Drawables are in the links, since I cannot upload images. The original picture is like in the first listview item in the exp_result.png. I want to use 1 picture for each - top, buttom and middle and to be used no matter the listview item size. XML is:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/list_up" >
<TextView
android:id="#+id/name_entry"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="28dip" />
<TextView
android:id="#+id/number_entry"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="28dip" />
</LinearLayout>
I can really really use some help here.
Yoav
This may be a good application of the 9-patch image type:
9-Patch

How to list view whole row selectable in android?

I created a sample application from Android sample tutorial and completed all 3 exercises for Notepad. I am able to add and edit notes created. However when I try to edit the notes I am force to select the text title for editing. If I click on to the right of the text, basically any where else In the same row I am not able to edit it.
I would like to make the whole row to be select-able/editable. Please let me know how to do this. I tried to change the notes_row.xml width="fill_parent". But this did not work out. Please help me out with this. Thank you.
change your notes_row.xml file
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:layout_height="wrap_content">
<TextView android:id="#+id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TextView">
</TextView>
</RelativeLayout>

android: which view should I use for showing text and image?

My app shows a list of items, where each line is an item title with its image asides, the line reserves 70% of space for text and 30% for image. Imagine what iphone app store looks like. Which view/layout combo is recommended for this purpose?
I googled and find this article:
http://www.curious-creature.org/2009/02/22/android-layout-tricks-1/
Does this view sound good?
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:padding="6dip">
<ImageView
android:id="#+id/icon"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:layout_marginRight="6dip"
android:src="#drawable/icon" />
<TextView
android:id="#+id/secondLine"
android:layout_width="fill_parent"
android:layout_height="26dip"
android:layout_toRightOf="#id/icon"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:singleLine="true"
android:ellipsize="marquee"
android:text="Simple application that shows how to use RelativeLayout" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/icon"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_above="#id/secondLine"
android:layout_alignWithParentIfMissing="true"
android:gravity="center_vertical"
android:text="My Application" />
If by the "what the iPhone app store looks like", you mean "pretty much every single list out there" (well, at least as far as I can judge by the description, having never actually seen the iPhone app store), there seems to be only one way which works. The 'ideal' solution would be to use a RelativeLayout as that allows you to have two lines of text next to the image without needing to a complex layout structure. However, as you can see in this question and this other question, there seems to be some issue with that. So, the fallback is to use a horizontal LinearLayout, and nest a second vertical LinearLayout in it if you need multiple lines of text. See those posts for more details about what your LinearLayout should look like.
Note: I'm assuming you know how to use a ListView. If you don't know how ListViews work, then I recommend this article as a good starting place. It's a bit old, but still good. Just make sure you read its sequels as well, which explain how to use the convertView optimisation.
Edit: For anyone else reading this, here is a tutorial on Lists with much better formatting, making it easier to read.
ListView with a custom layout for the row. When you create the ListAdapter(SimpleAdapter/ArrayAdapter) you can pass in a layout in the constructor. Its real easy if the image will always be the same, but if the image will vary you will need to override the getView method to create the view for the row.

Categories

Resources