getListView is missing
Your activity must inherit from a ListActivity
. Your class should start with
public class MyListAdapter extends ListActivity {
...
}
Then you can use the method
getListView()
This is the official documentation
Second solution
If you use a fragment, then you can access your ListView
by using
ListView lv = (ListView) rootView.findViewById(R.id.id_of_your_listView);
The rootView
is the view you get in your onCreateView
Method of the Fragment
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View rootView = inflater.inflate(R.layout.example_fragment, container, false);
return rootView;
}
Undefine getlistview method in activity
Please try following:
ListView lv = (ListView) findViewById(R.id.list);
Android - ListActivity to Activity
If you are using ListActivity then in your xml file just change this for ListView id
android:id="@android:id/list"
and in your Activity call this
ListView lv = getListView();
If you are using Activity then just find id of your ListView in your java file by
Listview mListView = (ListView) findViewById(R.id.myListView);
and set adapter for that
mListView.setAdapter(mAdapter);
Related Topics
Android 5.0: How to Change Recent Apps Title Color
How to Rotate Textview 90 Degrees and Display
How to Test Boot_Completed Broadcast Receiver in Emulator
Include Stetho Only in the Debug Build Variant
Yuv to Rgb Conversion by Fragment Shader
How to Change Actionbar Tab Indicator Programmatically
Change Shape Solid Color at Runtime Inside Drawable Xml Used as Background
Developing Two Android Apps and Communicating Between Two
Issues with Android Tabhost Example
Can't Access "Findviewbyid" in Asynctask
Android Error - Caused By: Java.Lang.Noclassdeffounderror: Android.Support.V4.Util.Sparsearraycompat
Difference Between Android: and App: Prefix in Android Xml
Setting Android Theme Background Color
Getting Header from Response (Retrofit/Okhttp Client)
How to Get Bluetooth Connected Devices Using Bluetoothheadset API
Android: How to Update a Imageview/Imagebutton with a Number to Show the Number of New Messages