android-arrayadapter

Custom spinner with object ArrayAdapter can't getResources

那年仲夏 提交于 2020-01-06 02:50:18
问题 I am using the tutorial here to create a custom spinner. When I copy the class CountryAdapter (half-way down the page), eclipse is not able to identify getResources() in myFlag.setBackgroundDrawable(getResources().getDrawable(item.getCountryFlag())); Does anyone know a fix to this problem? Basically, how else might I get the drawable? I am copying the class below public class CountryAdapter extends ArrayAdapter<CountryInfo> { private Activity context; ArrayList<CountryInfo> data = null;

“getView” - the constant change of position of Items and I have to click twice of “Item”

送分小仙女□ 提交于 2020-01-05 12:13:56
问题 I have a realization of ArrayAdapter (extends ArrayAdapter ), the method getView constantly redraw the screen,constantly changing position item of the ListView. But this is not the only problem. When I want to make text changes - are re-sorted . As well as to activate the line by setOnClickListener I have to click twice My source public View getView(int position, View convertView, ViewGroup parent) { UrlItem urlItem = (UrlItem) this.getItem(position); ViewHolder viewHolder = null; if

ListView not getting updated on calling notifyDataSetChanged()

China☆狼群 提交于 2020-01-05 12:11:07
问题 i want to add data into the listview when pressing the button. but it is not getting updated pressing the button dont know how it is not getting worked. Please help me. here is the code below @SuppressLint("NewApi") public class Messanger extends Activity { ArrayAdapter<String> adapter; ListView output; EditText box; String msg[]; Button btn; int counter=0; ArrayList<String> listItems; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);

custom arrayadapter get data from asynctask

旧时模样 提交于 2020-01-05 09:30:16
问题 i trying to connect with themoviedb.orgbut there's some issues MainActivityFragment.java public class MainActivityFragment extends Fragment { public Item[] dataAdapter ; public MainActivityFragment() { this.updateData(); } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Add this line in order for this fragment to handle menu events. setHasOptionsMenu(true); } @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {

How to acces variable in arrayadapter getView from onItemClick

与世无争的帅哥 提交于 2020-01-05 02:53:09
问题 I have an ArrayAdapter whose getView sets the items in the listview with data. When i click a row in the listview i'd like to start another activity, (which i can do), but send that activity some of the data to present in another view. How can i make the data from getView accessible in the onItemClick method? @Override public View getView(int position, View convertView, ViewGroup parent) { LayoutInflater inflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

GridView is not refreshing view after data changed

妖精的绣舞 提交于 2020-01-04 14:09:01
问题 I have a GridView with a custom adapter that wont refresh. In the debugger I can see that getView is not being called after notifyDataSetChanged . I have no idea why... I can see that the underlying data is being changed but nothing is happening to the GridView. I tried several solutions which didn't work, so I'm posting what I think should be the right one (even though it clearly isn't...) This is in my main activity private GridView grid; private TileGridAdapter gridAdapter; private

Custom ArrayList Adaptor - Displaying Icons in the ActionBar List

社会主义新天地 提交于 2020-01-04 09:30:10
问题 I am trying to add icons to my ActionBar (v7). I created a custom ArrayAdapter I want to display the appropriate icon next to the list item. However, I am getting the correct icon upon slection, not in the list itself public class ObjectsArrayAdapter extends ArrayAdapter<String> { private final Context context; private final String[] values; public ObjectsArrayAdapter(Context context, String[] values) { super(context, R.layout.objects_type_list, R.id.label, values); this.context = context;

Context menu in list activity

戏子无情 提交于 2020-01-04 02:52:10
问题 I have list activity with custom array adapter and I can't to get context menu when make long press on list item. <TabWidget android:id="@android:id/tabs" android:layout_width="fill_parent" android:layout_height="wrap_content"/> <FrameLayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="5dp"> <ListView android:id="@+id/list" android:layout_width="fill_parent" android:layout_height="fill_parent" /> </FrameLayout>

java.lang.NullPointerException at android.widget.ArrayAdapter.init(ArrayAdapter.java)

你。 提交于 2020-01-03 17:16:09
问题 lang.NullPointerException android.widget.ArrayAdapter.init(ArrayAdapter.java) just am adding Arraylist values into customAdapter class and setting that values into listview see below code helpm me thanks private void fetchCallLogsDetails(String selectedId) { this.SelectedLogId = selectedId; new FetchCallLogDetailsAsyncTask() { protected void onPostExecute(Boolean result) { if (mCallLogModel.getmPhoto() != null) { mCallLogPhoto.setImageBitmap(mCallLogModel.getmPhoto()); } mCallLogDetailName

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

馋奶兔 提交于 2020-01-03 10:59:11
问题 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