I have one Linear Layout which contains three List Views and Three Buttons. I have customized the List View elements. I just want that if anyone touches the element of a List View then the corresponding text view should give effect as a marquee.
The main Linear Layout is as below -
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:orientation="vertical" >
<ListView
android:id="@+id/list1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip"
android:layout_marginTop="5dip"
android:layout_weight="1"
android:drawSelectorOnTop="false"
android:textSize="16dip" />
<Button
android:id="@+id/more_button1"
android:layout_width="130dip"
android:layout_height="wrap_content"
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip"
android:layout_marginTop="5dip"
android:text="More" >
</Button>
<ListView
android:id="@+id/list2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip"
android:layout_marginTop="5dip"
android:layout_weight="1"
android:drawSelectorOnTop="false"
android:textSize="16dip" />
<Button
android:id="@+id/more_button2"
android:layout_width="130dip"
android:layout_height="wrap_content"
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip"
android:layout_marginTop="5dip"
android:text="More" >
</Button>
<ListView
android:id="@+id/list3"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip"
android:layout_marginTop="5dip"
android:layout_weight="1"
android:drawSelectorOnTop="false"
android:textSize="16dip" />
<Button
android:id="@+id/more_button3"
android:layout_width="130dip"
android:layout_height="wrap_content"
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip"
android:layout_marginTop="5dip"
android:text="More" >
</Button>
</LinearLayout>
Customized List Items are as below (list_item_1, list_item_2, list_item_3)-
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:ellipsize="marquee"
android:focusableInTouchMode="true"
android:freezesText="true"
android:lines="1"
android:marqueeRepeatLimit="marquee_forever"
android:padding="10dp"
android:scrollHorizontally="true"
android:scrollbarAlwaysDrawVerticalTrack="false"
android:singleLine="true"
android:textSize="20sp" >
</TextView>
And the activity is as below -
public class MarqueeActivity extends Activity {
ListView lv1 = null;
ListView lv2 = null;
ListView lv3 = null;
String s1[] = {"Hello This is a long Text which will help in tsting", "How", "Are", "You"};
String s2[] = {"I", "Am", "Fine"};
String s3[] = {"Welcome", "In", "New", "World"};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
lv1 = (ListView) findViewById(R.id.list1);
lv2 = (ListView) findViewById(R.id.list2);
lv3 = (ListView) findViewById(R.id.list3);
lv1.setAdapter(new ArrayAdapter<String>(this, R.layout.list_item_1, s1));
lv2.setAdapter(new ArrayAdapter<String>(this, R.layout.list_item_2, s2));
lv3.setAdapter(new ArrayAdapter<String>(this, R.layout.list_item_3, s3));
}
}
For e.g. If the activity is started and then someone touches the first element in first list view (Hello This is a long Text which will help in testing) then it should start marquee.
Thanks in advance!!