activity.xml file
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"> <ListView
android:id="@+id/LVcustomlist"
android:layout_width="match_parent"
android:layout_height="match_parent"> </ListView> </LinearLayout>
Mainactivity.java file
import android.support.v7.app.AppCompatActivity; import android.os.Bundle;import android.widget.ArrayAdapter; import android.widget.ListView;public class MainActivity extends AppCompatActivity { // Array of strings... String[] mobileArray = {"Android","IPhone","WindowsMobile","Blackberry", "WebOS","Ubuntu","Windows7","Max OS X"}; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ArrayAdapter adapter = new ArrayAdapter<String>(this, R.layout.activity_listview, mobileArray); ListView listView = (ListView) findViewById(R.id.LVcustomlist); listView.setAdapter(adapter); }}output on mobile screen look like this..
No comments:
Post a Comment