Demo:
3.Activity:
1.main.xml:
<?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:background="#5F04B4"
android:orientation="vertical"
>
<ListView
android:id="@+id/lvList"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
/>
</LinearLayout>
2.style.xml:
<?xml version="1.0"
encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:gravity="center_vertical"
android:textColor="#ffffff"
android:textSize="20dp"
/>
3.Activity:
package
com.venky.listviewpassingownstyle;
import
android.app.Activity;
import
android.os.Bundle;
import
android.widget.ArrayAdapter;
import android.widget.ListView;
public class
ListViewpassingOwnStyleActivity extends Activity {
/** Called when the activity is first
created. */
ListView lvList;
String[] Languages = { "Telugu", "English", "Hindi", "Tamil", "Kanada",
"Urdu", "Punjabi", "etc" };
@Override
public void onCreate(Bundle
savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
lvList = (ListView) findViewById(R.id.lvList);
ArrayAdapter<String> adapter =
new
ArrayAdapter<String>(this,
R.layout.style, Languages);
lvList.setAdapter(adapter);
}
}
4)Download this Project Click Here
No comments:
Post a Comment