android-listview

Is ListView completely inferior to RecyclerView?

…衆ロ難τιáo~ 提交于 2019-12-04 05:38:36
So, Vogella seems to suggest that ListView is completely being deprecated in comparison with RecyclerView. And not actually deprecated, but rather that there is no situation in which ListView would be a better choice. Is this true? The commonsware book suggests that it might be faster at updating. Is there any other reason to completely avoid ListView from now on? Just reading through some examples, it seems that RecyclerView adds many layers of difficulty/convolution to the code, hence my desire to avoid using such unless there's a very good reason (animation isn't a superb-enough reason)

How to get all children (visible and invisible) from a ListView?

冷暖自知 提交于 2019-12-04 05:37:55
My problem is similar to ListView getChildAt returning null for visible children , but despite searching I cannot find a solution. I have a ListView with a Scroll. The ListView has 10 items, 7 of which are visible and 3 are hidden by scroll. I also have an external method (out of adapter) that must get all of the children from this ListView (e.g. using getChildAt() ). I need all 10 of the items, but the last 3 are null objects. I've tried code like the following: getListView().smoothScrollToPosition(); But this doesn't work. I think that I don't need to post the rest of my code, as the

click event for all dynamic generated buttons android

你说的曾经没有我的故事 提交于 2019-12-04 05:30:58
问题 I write code to generate dynamic buttons , but I don't know how to implement click event for each button dynamically. I found some answers but not work with my code... Please help me.. This is my code public class dynamicbuttion extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ScrollView sv = new ScrollView(this); LinearLayout ll = new LinearLayout(this); ll.setOrientation(LinearLayout.VERTICAL); sv.addView(ll); for(int i = 0;

Force onSizeChanged for ListView

北战南征 提交于 2019-12-04 05:24:34
I have a listview which gets assigned with different datasets dynamically. This works fine. I have also made fastScrollEnabled to be true. For the sectionIndexer to be updated I need to call list.setFastScrollEnabled(false); list.setFastScrollEnabled(true); The problem is the index shows in top left and this is a know issue. As a work-around whenever I change the orientation the index is again correctly shown. To test this I have implemented a custom ListView and the observation is if I can force listView to call onSizeChanged() it will show up properly. Now the question: Is it possible to

How to correctly use TextSwitcher in ListView?

假装没事ソ 提交于 2019-12-04 05:07:49
My TextSwitcher for each record in ListView should display first value ( text1 ) and then another value ( text2 ), then first value again and so on. It should happen only if text2 not empty. Otherwise text1 should be always shown (without any changes and animation). I've created Runnable() , which changes boolean variable ( time2 ) to then call items.notifyDataSetChanged() . It works as expected and in result setViewValue() for my ListView is called. Here is the code: items.setViewBinder(new SimpleCursorAdapter.ViewBinder() { @Override public boolean setViewValue(View view, Cursor cursor, int

Populate ListView on Fragment after Async done from Activity

巧了我就是萌 提交于 2019-12-04 05:04:30
I have main activity which will get JSON data from a url async This is MainActivity.java public class MainActivity extends FragmentActivity implements ActionBar.TabListener{ private ViewPager viewPager; private TabsPagerAdapter mAdapter; private ActionBar actionBar; //Tab titles private String[] tabs = {"Sermons", "More"}; private String[] sermonsList = new String[0]; //JSON URL for sermonList data private static String sermonListJSONUrl = "https://dl.dropboxusercontent.com/u/12345/index.php"; //Variable to save JSON Object private static final String JSON_KEY_SERMONS = "sermon"; private

list view java.lang.IllegalStateException even after calling notifyDataSetCanged();

时间秒杀一切 提交于 2019-12-04 04:55:21
问题 java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification. Make sure the content of your adapter is not modified from a background thread, but only from the UI thread. my list-view contains huge data`s am calling the bellow code using handler when the data is changed in the list listviewAdapter.notifyDataSetChanged(); but i get the same error some times and not every time i load it thanks in advance 回答1: the question is not where the

Android Espresso ListView click item

a 夏天 提交于 2019-12-04 04:45:35
I have ListView with pictures and text. When I try to click item, I get error android.support.test.espresso.AmbiguousViewMatcherException: 'with id: com.cifrasoft.telefm:id/cardsGridView' matches multiple views in the hierarchy. Problem views are marked with '****MATCHES****' below. I use the following code: onData(hasToString(startsWith("Item Text"))) .inAdapterView(withId(R.id.cardsGridView)) .perform(click()); Can I click ListView using position of Adapter , without matches or startWith ? Try with atPosition(). e.g. onData(hasToString(startsWith("Item Text"))) .inAdapterView(withId(R.id

How to set custom ListAdapter to list view in appwidget?

强颜欢笑 提交于 2019-12-04 04:28:43
问题 I have a listView. I needed a custom view for each list item, so I've created a custom ListAdapter which gives the views, layout for which is given below. But how do I set this listAdapter to the ListView in the widget using RemoteViews ? <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@android:color

Android RecyclerView Edittext issue

一世执手 提交于 2019-12-04 04:27:50
I'm creating a list of editable items (received from backend). I'm using the "new" recyclerview for this. There a couple of possible viewTypes in my recyclerview: checkbox spinner edittext The problem I'm having is with the EditText gaining focus. AdjustResize kicks in fine and my keyboard is shown. But the EditText that has gained focus isn't visible anymore in the list. (position in the list in the now resized portion is below the visible positions). I don't want to be using AdjustPan in this case because on top there is a pager & stuff I would like to keep fixed there.. This is happening