android-arrayadapter

How can I create a list with only certain items expandable?

杀马特。学长 韩版系。学妹 提交于 2020-01-03 10:58:08
问题 I am trying to compose a list with some items expandable and some single items. I wish to have it so that when either a single item or expandable list child is clicked, I can call an intent based on the text of the item. I suppose expandable lists would work, but is there a way to set items in an expandable list so that they don't have the expandable list icon? Should I use something other than a string array? What is the best way to do this? Thanks Below is my incomplete code, I would like

android listview not working

浪尽此生 提交于 2020-01-03 05:37:34
问题 i am new to android development, and i just learnt about list views and array adapters etc. I have a project in android studio that has multiple activities and in one i have a array adapter and a list view, but every time i run the app and switch to the activity that has the list view in it the app does not respond and it closes. I have checked the code and it is the same as the code in the several tutorials i have seen. I think that it has something to do with the multiple activities i have,

convertView.getTag(); creates Cast Error

泄露秘密 提交于 2020-01-02 06:24:07
问题 I'm using a fragment to create a ListView filled with CheckBox es. I tried my best to find the solution based on other questions but I can't seem to fix it. When I run the script without using the: convertView.getTag(); My app runs fine but the positions of the Item s in the list don't save so. The view items jump around. However when I do use that method I get an error. The log cat states: 01-02 23:54:20.662: E/InputEventReceiver(1209): Exception dispatching input event. 01-02 23:54:20.672:

EditText in a List Adapter, how to save the value?

谁说胖子不能爱 提交于 2020-01-02 04:58:05
问题 So, I have a custom adapter with two EditText fields on every row. I've gotten most of the stuff working properly, except saving the values inside the ArrayList. This is the code I've done so far: private void holderTitleSavedOnScroll(final int position, IZUICartViewHolder holder) { if (!(position == (variantArrayList.size() - 1)) && holder.title != null) { holder.title.setText(variantArrayList.get(position).getVariantTitle()); final int finalPosition = position; holder.title

onItemClickListener with custom adapter and listview

烈酒焚心 提交于 2020-01-01 05:19:27
问题 I am trying to set an onItemClickListener with a custom adapter and listview setup. Can't seem to get the listener working. I don't think I am setting it up properly. Any help is appreciated. Thanks very much. Adapter: public class ModuleAdapter extends ArrayAdapter<Module> { Context context; int layoutResourceId; Module data[]; public ModuleAdapter(Context context, int layoutResourceId, Module data[]) { super(context, layoutResourceId, data); this.layoutResourceId = layoutResourceId; this

Refreshing ArrayAdapter onResume [notifyDataSetChanged() not working]

微笑、不失礼 提交于 2020-01-01 04:49:11
问题 I am creating a contact list app using Fragments where one frag is a list of names in the contact list and the other is the rest of the details. Here is the class that displays the list of names public class MyListFragment extends ListFragment { private ContactStorage contactStorage = new ContactStorage(); public final static String TAG = "FRAGMENTS"; private MainActivity parent; ArrayAdapter<String> adapter; ArrayList<String> entries = new ArrayList<String>(); String array[]; public View

Android Array Adapter with ArrayList and ListView not updating when the arraylist is changed

偶尔善良 提交于 2019-12-31 13:30:22
问题 I have an android app with a screen that comprises of a ListView, which I am using to display a list of devices. These devices are held in an array. I am trying to use the ArrayAdapter to display what is in the array on the screen in a list. It works when I first load the SetupActivity class, however, there is the facility to add a new device in the addDevice() method, which means the array holding the devices is updated. I am using notifyDataSetChanged() which is supposed to update the list

Cannot resolve constructor ArrayAdapter(android.Content.Context, int, java.util.ArrayList<MyObject>)

时光总嘲笑我的痴心妄想 提交于 2019-12-31 05:21:46
问题 I know this question has been asked a million times before, but I have tried all of the solutions I can find, and still doesn't work. I have tried calling "this" for context, I have tried getActivity, I have tried getContext(), but nothing seems to work for this fragment in particular. The same code does work in a different fragment tho, which is why I am really confused. Any help appreciated. My LoginFragment, my issue can be found in setReservations(): public class LoginFragment extends

Android notifyDataSetChanged not working

我与影子孤独终老i 提交于 2019-12-31 04:17:06
问题 I have an adapter which fills a ListView with 2 TextViews with data from a TreeMap. When the user adds or deletes Data from the ListView, the View should be refreshed. So here is my Adapter: public class MyAdapter extends BaseAdapter { private final ArrayList mData; public MyAdapter(Map<String, String> map) { mData = new ArrayList(); mData.addAll(map.entrySet()); } @Override public int getCount() { return mData.size(); } @Override public Map.Entry<String, String> getItem(int position) {

How to use an ArrayAdapter in a Fragment with Kotlin

可紊 提交于 2019-12-30 10:36:26
问题 I am trying to to create a Spinner inside a Fragment but I am getting error in the ArrayAdapter constructor call. I don't know why, but it has a red underline. Other than that, there is no error. When I'm using the same ArrayAdapter in an Activity it works, but in a Fragment , it gives an error. My FirstFragment.kt : class FirstFragment : Fragment() { private var mListener: OnFragmentInteractionListener? = null override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?,