Showing posts with label Android ListView. Show all posts
Showing posts with label Android ListView. Show all posts

Tuesday, December 24, 2013

Full example of using Fragment in Android Development

Fragment in Android is very useful for responsive layout design. In the post, I will give you a full detailed example of using FramentActivity in android application development.

We will produce a demo application which have two different layouts in different device.


Wednesday, December 26, 2012

Search in Custom ListView On Button Click Example


SEARCH IN CUSTOM LISTVIEW ON BUTTON CLICK

SOURCE CODE [main.xml] is

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:orientation="vertical"
android:layout_width="fill_parent"
                android:layout_height="fill_parent">

                <Button android:text="Search"
android:id="@+id/Button01"
                                android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
                                android:layout_width="wrap_content"
android:layout_height="wrap_content">
</Button>

                <EditText android:layout_width="fill_parent"
                                android:layout_height="wrap_content"
android:text="" android:id="@+id/EditText01"
                                android:layout_toLeftOf="@+id/Button01">
</EditText>

                <ListView android:layout_height="wrap_content"
                                android:layout_below="@+id/EditText01"
android:layout_width="wrap_content"
                                android:id="@+id/ListView01">
</ListView>
                                
</RelativeLayout>

Android - Custom ListView Example


CUSTOM LISTVIEW

SOURCE CODE [main.xml] is

<?xml version="1.0" encoding="utf-8"?>
<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="@+id/ListView01"
android:layout_height="wrap_content"
                                android:layout_width="fill_parent">
</ListView>

</LinearLayout>

Show a context menu for long-clicks in an Android ListView


AN ACTIVITY WITH AN EXPANDING LISTVIEW

Creating a Simple ListView

If you have an activity that will only contain a single ListView control, you can derive your activity from the ListActivity instead of Activity. However, I think I might like to show some extra info below my ListView so I chose to have a separate ListView object. My activity layout (main.xml) looks like this:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:orientation="vertical">
                <ListView android:id="@+id/ listview "
                                 android:layout_width="fill_parent"
                                android:layout_height="wrap_content"
                                android:layout_weight="1" />
</LinearLayout>

Android ListView OnClick Example


LISTVIEW ONCLICK
 
SOURCE CODE [main.xml] is 


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/LinearLayout01"
                android:layout_width="fill_parent"
android:layout_height="fill_parent"
                xmlns:android="http://schemas.android.com/apk/res/android">
                <ListView android:id="@+id/listview"
android:layout_width="wrap_content"
                                android:layout_height="wrap_content" />
</LinearLayout>

Android Search in ListView Example


SEARCH IN LISTVIEW


SOURCE CODE [main.xml] is


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/LinearLayout01"
                android:layout_width="fill_parent"
android:layout_height="fill_parent"
                xmlns:android="http://schemas.android.com/apk/res/android"
                android:orientation="vertical">
<EditText android:id="@+id/EditText01"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:hint="Search">
</EditText>

<ListView android:id="@+id/ListView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>

Android Simple ListView Example


SIMPLE LISTVIEW
 

SOURCE CODE [main.xml] is 


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/LinearLayout01"
                android:layout_width="fill_parent"
android:layout_height="fill_parent"
                xmlns:android="http://schemas.android.com/apk/res/android">
                <ListView android:id="@+id/listview"
android:layout_width="wrap_content"
                                android:layout_height="wrap_content" />
</LinearLayout>

Popular Posts