In my android application I want the ListView items to move from right to left and show extra options for that row. I don't know how to ask my question so I want to show you the pictures that I took. How can I do that or what it is called ?
This is the first state.
This is the secondstate (after click on the "PLUS" icon on the right side).
This was the final state which shows the extra choices
Is it possible that a ViewPager could be used?
I'm not sure that it would work for only a small part of the screen, but it could be worth a try... :)
More info can be found here (d.android.com)
UPDATE : Thanks to "ToVine", I researched for View Transitions. ViewFlipper suits for what I mentioned belove :). This is my custom listview row's xml.
<ViewFlipper xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:onClick="buttonClickHandler" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
<ImageButton
android:id="#+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#null"
android:onClick="buttonClickHandler"
android:src="#android:drawable/btn_star_big_on" />
</LinearLayout>
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:text="TextView2" />
</ViewFlipper>
Related
i have some views within a scrollview in a xml file.i want to change the title of the action bar while scrolling up.anyaone please help me how to do that..
this is my xml file
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="name"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="email"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="address"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
</ScrollView>
You want to observe the scrollview's scrolling? For whatever reason you can't do this via the Android SDK for scrollviews (you can for listviews however). As a result there are whole libraries!
https://github.com/ksoichiro/Android-ObservableScrollView
Or you can easily implement something similar fairly simpply such as
https://stackoverflow.com/a/3952629/3865761 if it meets your needs. Standing on the shoulders of stack overflow giant's as it were.
Once you can detect the scrolling, simply have methods such as onScrollUp() that increases the font size for your textviews, and resetTextViewState() which sets it back to its default called from the onScrollingChanged() callback you implement.
I want to create a list view layout with a image and title in it. I want a layout like listview in google io 2014 app. It should be a tiled listview with some colour till the image gets loaded, after the image is loaded it should be shown in the upper half of the listview and title should be shown below with some background colour. I am attaching the screenshot of google io app here.
Updated: If somebody can point me some template custom layout for this listview it would be helpful!
Create a custom list with all the needed controls in separate layout and inflate it using a custom adapter you can find a small example here
you could create a custom layout something like this
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="match_parent"
android:background="#drawable/images"
android:layout_height="match_parent"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#862c10">
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#android:color/white"
android:textSize="15sp"
android:layout_marginLeft="10dip"
android:textStyle="bold"
android:text="HTML5 everywhere how and why android users use the webplatform" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#android:color/white"
android:textSize="15sp"
android:layout_marginLeft="10dip"
android:layout_marginTop="10dip"
android:text="Wed 5 2001" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#android:color/white"
android:textSize="15sp"
android:layout_marginLeft="10dip"
android:layout_marginTop="10dip"
android:text="Steven roberts and mark robinson " />
</LinearLayout>
</LinearLayout>
(this should not be the answer, but forgive me I could not add a comment, and actually I hope this will give him the answer).
First of all I guess you didn't get on well with using ListView and Adapter in Android. So I suggest you to read the following article first:
ListView tutorial 1
ListView tutorial 2
They will teach you how to use xml to define your custom row view. Then you will know how to use George Thomas's xml. Try how to implement the getView() method.
to explain the situation :
-i have a listview filled with multiple rows, now i want to take any row and swipe left or right;
either way i need to show another view behind the current row as i swipe( kind of the sliding menu with the action bar, although i dont think i can use that in my case)
when the user swipes left for example the new view can have an offset, (or doesnt), so it may or may not cover the whole row, any suggestions ?
thanks a lot
random code()
<ListView
android:id="#+id/lvWatchlists"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/relativeLayout1"
android:layout_below="#+id/header_l" >
</ListView>
<RelativeLayout
android:id="#+id/relativeLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#004c98" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/donnees" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="#+id/imageView1"
android:text="#string/differe"
android:textColor="#color/title_selected"
android:textSize="#dimen/footer_text" />
<TextView
android:id="#+id/maj2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="10dp"
android:text="00/00/00 à 00:00:00"
android:textColor="#color/title_selected"
android:textSize="#dimen/footer_text" />
<TextView
android:id="#+id/maj1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toLeftOf="#+id/maj2"
android:text="#string/maj_le"
android:textColor="#color/title_selected"
android:textSize="#dimen/footer_text" />
</RelativeLayout>
use swipeable list view library from here
https://github.com/47deg/android-swipelistview
or check this open sourced program for the same feature by roman nurik
https://code.google.com/p/dashclock/source/browse/main/src/main/java/com/google/android/apps/dashclock/ui/SwipeDismissListViewTouchListener.java
It depends what you or doing on by swiping the row view, deleting it or something else
I am trying a task that should probably be simple..I want one button at the bottom across the bottom of the screen (floating preferably), while I have a scrollable list above that (I was able to do this in a tutorial with a simple listview and buitton).But, my list is a LinearLayout that I fill with a SimpleCursorAdapter and a viewBinder. Since I am using this LinearLayout I keep getting One button per line item, instead of one at the bottom of the screen. I have tried wrapping it with a table layout, relative layout, using two LinearLayouts, etc. Every time I get one button per line. Is this because of the way I am getting the data with a cursor adapter and filling it into the listview? Do I need to use a "merge" in my xml file? Is there a way to make two xml files and then call them both? Do I need to switch to a ListView or another way of displaying the data? This is my first app that I am trying start to finish on my own, so some of this stuff trips me up. I will include my code for the LinearLayout, please note that this is just the list without my extra button added (i deleted all my failed attempts). So I would be looking to modify the code below to contain one button that floats at the bottom of the screen all the time.
<LinearLayout android:id="#+id/LinearLayout01"
android:layout_width="290dp"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:hapticFeedbackEnabled="true">
<Button
android:id="#+id/BtnToClick"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="myClickHandler"
android:drawableLeft="#+drawable/android_button"
android:gravity="left|center_vertical"
android:background="#android:color/transparent"
android:hapticFeedbackEnabled="true"
android:layout_weight=".1">
</Button>
<TextView android:text=""
android:id="#+id/tvViewRow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone">
</TextView>
<TextView android:text="#+id/text11"
android:id="#+id/text11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone">
</TextView>
<TextView
android:id="#+id/text5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="3dip"
android:gravity="left|center_vertical"
android:layout_weight=".20"/>
<TextView
android:id="#+id/text9"
android:layout_column="5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="3dip"
android:gravity="center|center_vertical"
android:layout_weight=".1"/>
<TextView
android:id="#+id/text10"
android:layout_column="6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="3dip"
android:gravity="left|center_vertical"
android:layout_weight=".15"/>
<TextView
android:id="#+id/text12"
android:layout_column="8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
android:padding="3dip"
android:gravity="left|center_vertical" />
<Button
android:id="#+id/BtnToClick2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="myClickHandler3"
android:gravity="center|center_vertical"
android:background="#+drawable/coup0a"
android:hapticFeedbackEnabled="true"
>
</Button>
Thanks in advance!
-Joe
You need to add the button as a footer or a header according to your needs. You can try this code .The R.layout.header and footer are separate xml layout files which you would have to define.
View header = inflater.inflate(R.layout.header,null);
View footer = inflater.inflate(R.layout.footer,null);
addHeaderView(header);
addFooterView(footer);
You should absolutely use a listview for this job. Listviews are highly optimized for displaying many entries. Just let your activity extend from a ListActivity and create a layout xml file with a listview widget that has the id "#android:id/list" and the listview activity will hook onto that list automatically. You are free to place other widgets in the layout aswell. Here is an example layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView
android:id="#android:id/list"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
/>
<Button
android:id="#+id/chooseOther"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/add_fav"/>
</LinearLayout>
It has a list with a button sitting on the bottom of the screen at all times, even if you have a long list of items.
I have a layout with 3 button at the top in a row and then a ListView followed by a button below the listView.
This is my layout.xml file
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Button android:id="#+id/btn_top10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TOP 10"/>
<Button android:id="#+id/btn_top100"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TOP 100"
android:layout_toRightOf="#id/btn_top10"/>
<Button android:id="#+id/btn_showAll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Show All"
android:layout_toRightOf="#id/btn_top100"/>
<ListView android:id="#+id/LV_Device"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/btn_top10"
android:layout_above="#id/LV_Device"/>
<Button android:id="#+id/btn_clearResult"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Clear Results"
android:layout_below="#id/LV_Device"/>
</RelativeLayout>
This will give a result like this
If i add some values to the ListView then its ok, the button below will be show
But if the listview becomes larger than the screen size then the button below that will not be visible even after scrolling to the bottom of the listView
How to solve this issue?? I don't want button to be fixed at the bottom of the screen. I want the button to be show at the end of the ListView only
Change your ListView's height to 0dip. Then change the attribute
android:layout_above="#id/LV_Device"
to
android:layout_above="#+id/btn_clearResult"
Finally, modify the last button by removing android:layout_below and add instead android:layout_alignParentBottom="true".
If you got the answer, this is for those who still come in search of the answer for your question. You should be using ListView.addFooterView(yourbutton) to your list.
(but don't forget to put this statement before setting adapter for your listview, as stated in the document.)
Shijilal
you maybe try this
your top button
your bottom group button
put your RelativeLayout in a scroll view this way your button will be displayed even after the scroll use this might work
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/ScrollView01"
android:layout_width="fill_parent"
android:paddingTop="10dip"
android:layout_height="fill_parent"
android:paddingBottom="10dip">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Button
android:id="#+id/btn_top10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TOP 10" />
<Button
android:id="#+id/btn_top100"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TOP 100"
android:layout_toRightOf="#id/btn_top10" />
<Button
android:id="#+id/btn_showAll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Show All"
android:layout_toRightOf="#id/btn_top100" />
<ListView
android:id="#+id/LV_Device"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/btn_top10"
android:layout_above="#id/LV_Device" />
<Button
android:id="#+id/btn_clearResult"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Clear Results"
android:layout_below="#id/LV_Device" />
</RelativeLayout>
Initialy no item in the listView.so clear result button at the top. After add some item clear button goes down. But when more items are added clear button goes down & out of screen resolution. I want to know that Initialy when items are added clear button goes down. when clear button reached at bottom then it will not goes down further. you can add more items in the list view.