public class AddNewRequestActivity extends Activity {
protected void onCreate(Bundle savedInstanceState) {
// create a BroadcastReceiver
br = new BroadcastReceiver() {
// actions when receiving messages
public void onReceive(Context Context, Intent intent) {
String[] names = { "John", "Mary", "Peter", "Anton", "Dora", "Boris",
"Kostya", "Igor", "Anna", "Denis", "John" };
// find the list
ListView lvMain = (ListView) findViewById(R. id.listViewRequests);
// create the adapter
ArrayAdapter<string> adapter = new ArrayAdapter<string>(AddNewRequestActivity.this, android.R.layout.simple_list_item_1, names);
// assign adapter to list
lvMain.setAdapter(adapter);
}
};
// create a filter for BroadcastReceiver
IntentFilter intFilt = new IntentFilter(BROADCAST_ACTION);
// pending (include) BroadcastReceiver
registerReceiver(br, intFilt);
}
}</string></string>
Find more questions by tags Android
String[] names = { "John", "Mary", "Peter", "Anton", "Dora", "Boris",
"Kostya", "Igor", "Anna", "Denis", "John" };
// find the list
ListView lvMain = (ListView) findViewById(R. id.listViewRequests);
// create the adapter
ArrayAdapter adapter = new ArrayAdapter(AddNewRequestActivity.this, android.R.layout.simple_list_item_1, names);
// assign adapter to list
lvMain.setAdapter(adapter);
in OnCreate of activity, then it works. and if you insert in your BroadcastReceiver? the list is empty. - Marlin_Ritchie commented on July 8th 19 at 16:03
Throw TabHost. Throw ListView. B 2016 live, after all. - Art_Christians commented on July 8th 19 at 16:06
https://developer.android.com/reference/android/su...
https://developer.android.com/reference/android/su... - Art_Christians commented on July 8th 19 at 16:12