android-arrayadapter

“new ArrayAdapter<String>(this ” error when used in dialog null exception

懵懂的女人 提交于 2019-12-12 04:42:44
问题 hi, I have been working on a dialog box and i need a ListView inside the dialog box. The problem is i cant use "this" "new ArrayAdapter(this" Can someone help me? ListView dialog_ListView = (ListView)dialog.findViewById(R.id.list); ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, comment11); dialog_ListView.setAdapter(adapter); 回答1: Maybe this workaround helps you: ListView dialog_ListView = (ListView)dialog.findViewById(R.id.list);

Android JSONObject to ListView

主宰稳场 提交于 2019-12-12 04:10:14
问题 I'm having a problem here, I'm totally new at this. What i try to do is pass a JSONObject to my adapter and inside my adapter create all rows for that ListView This is my code: private static final String TAG_OS = "android"; protected void onPostExecute(JSONObject json) { try { JSONArray jArray = json.getJSONArray(TAG_OS); if (jArray != null) { for (int i=0;i<jArray.length();i++){ listdata.add(jArray.get(i).toString()); } } menu_list=(ListView)findViewById(R.id.menu_list); MenuAdapter adapter

I am trying to implement a custom listview using ArrayAdapter but all the items are not showing in the screen

怎甘沉沦 提交于 2019-12-12 03:59:00
问题 MainActivity.java public class MainActivity extends Activity { ListView list; String[] titles; String[] description; int imgs[]={R.drawable.facebook,R.drawable.instagram,R.drawable.twitter,R.drawable.google}; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Resources res = getResources(); titles = res.getStringArray(R.array.titles); description = res.getStringArray(R.array.description); list = (ListView)

ArrayAdapter possibly causes app to crash

主宰稳场 提交于 2019-12-12 03:55:30
问题 I am having a problem moving forward with my app. I just started developing the app and only have about 15 hours involved so far. But I have hit a snag. Usually I am able to google snags and most of my answers come from this forum! so I hope I can find a solution for this. Below is my activity java file. This is where the issue is as it was working fine before. I have been having a ton of trouble with showing my list using an array adapter. public class Favorites extends Activity{

Android: listview array adapter not wrapping content correctly

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-12 03:38:38
问题 I have a Theme.Dialog activity that presents a list of devices to a user. the activity uses a ListView with a dynamically created ArrayAdapter to display the list of devices. For some reason however, the ListView (and thus the activity itself) isn't resizing to wrap it's content correctly. Instead, it acts as if it's got a set width of about half the screen (and this persists across devices with different screen sizes). I can't for the life of my figure out where this is set, though. Can

ParseUser Username Adapter in Android ListView doesn't show Data

拜拜、爱过 提交于 2019-12-12 03:16:57
问题 im trying to show the usernames of all the people in my Parse.com User.class in an Android ListView, but it won't show any Data if I execute it. It runs on my Samsung Galaxy S2 with Android 4.1.2 The Code: // Create and populate an ArrayList of objects from parse final ArrayAdapter<String> listAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1); final ListView userlist = (ListView) findViewById(android.R.id.list); userlist.setAdapter(listAdapter); final ParseQuery

ArrayAdapter contains an object based on a value

不问归期 提交于 2019-12-12 03:08:19
问题 I have a ListView and ListView adapter. I am adding objects to the adapter but I only want to add one row with an object that contains a certain String . This is my code but it does not work: public static List<FriendsVideoLVModel> list = new ArrayList<FriendsVideoLVModel>(); @Override public void add(FriendsVideoLVModel obj) { super.add(obj); for (int i=0; i <list.size(); i++) { if (!obj.eventTitle.equals(list.get(i).eventTitle)) { list.add(obj); notifyDataSetChanged(); } } } Please help.

Android Custom AutoCompleteTextView with Custom Adapter

妖精的绣舞 提交于 2019-12-12 02:52:15
问题 Basically, I wish to write something in the edittext, then a web http request will be called that returns a JSONObject which contains a JSON array, which contain the values somewhere inside it. I need to populat the dropdown list that comes with autocompletetextview with the results from the JSON Object. I can do the second bit, i.e. I can populate the dropdown list with the values I need by using a custom adapter class that extends arrayadapter as u can see below. My problem is with the

Add custom checkbox to ArrayAdapter

孤街浪徒 提交于 2019-12-12 02:46:44
问题 I am using SQLite database to save my records, on returning them I am using this code: mydb = new DBHelper(this); ArrayList array_list = mydb.getAllItems(); ArrayAdapter arrayAdapter=new ArrayAdapter(this,android.R.layout.simple_list_item_1, array_list); mRecyclerview =(RecyclerView) findViewById(R.id.items_List); obj = (ListView)findViewById(R.id.listView1); obj.setAdapter(arrayAdapter); But this is showing me a normal list of items and I want to display a list with CheckBox on every row. I

delete a row from a listview android

浪子不回头ぞ 提交于 2019-12-12 02:03:16
问题 I have three textviews and a button in each row of my listview , on button click i want to remove the paticular row from the listview. I have tried many codes but without any success. Please do help.Thanks in advance!!! VivzAdapter adapter=new VivzAdapter(this,foodname,quantity,amount); view.setAdapter(adapter); view.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view2, int position, long id) { int itemPosition = position;} }); } } class