Why `PagerAdapter::notifyDataSetChanged` is not updating the View?

There are several ways to achieve this. The first option is easier, but bit more inefficient. Override getItemPosition in your PagerAdapter like this: public int getItemPosition(Object object) { return POSITION_NONE; } This way, when you call notifyDataSetChanged(), the view pager will remove all views and reload them all. As so the reload effect is obtained. … Read more

android – listview get item view by position

Use this : public View getViewByPosition(int pos, ListView listView) { final int firstListItemPosition = listView.getFirstVisiblePosition(); final int lastListItemPosition = firstListItemPosition + listView.getChildCount() – 1; if (pos < firstListItemPosition || pos > lastListItemPosition ) { return listView.getAdapter().getView(pos, null, listView); } else { final int childIndex = pos – firstListItemPosition; return listView.getChildAt(childIndex); } }

How to customize listview using baseadapter

main.xml: <RelativeLayout xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:tools=”http://schemas.android.com/tools” android:layout_width=”match_parent” android:layout_height=”match_parent” android:paddingBottom=”@dimen/activity_vertical_margin” android:paddingLeft=”@dimen/activity_horizontal_margin” android:paddingRight=”@dimen/activity_horizontal_margin” android:paddingTop=”@dimen/activity_vertical_margin” tools:context=”.MainActivity” > <ListView android:id=”@+id/list” android:layout_width=”match_parent” android:layout_height=”wrap_content” android:layout_alignParentLeft=”true” android:layout_alignParentTop=”true” > </ListView> </RelativeLayout> custom.xml: <?xml version=”1.0″ encoding=”utf-8″?> <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”match_parent” android:layout_height=”match_parent” android:orientation=”vertical” > <LinearLayout android:layout_width=”match_parent” android:layout_height=”wrap_content” > <LinearLayout android:layout_width=”255dp” android:layout_height=”wrap_content” android:orientation=”vertical” > <LinearLayout android:layout_width=”match_parent” android:layout_height=”wrap_content” android:orientation=”vertical” > <TextView android:id=”@+id/title” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:text=”Video1″ android:textAppearance=”?android:attr/textAppearanceLarge” android:textColor=”#339966″ android:textStyle=”bold” /> </LinearLayout> … Read more

Custom Adapter getView() method is not called

The only reasons getView is not called are: getCount returns 0. you forget to call setAdapter on the ListView. If the ListView‘s visibility (or its container’s visibility) is GONE. Thanks to @TaynãBonaldo for the valuable input. ListView is not attached to any viewport layout. That is, mListView = new ListView(…) is used without myLayout.addView(mListView). In … Read more

Update data in ListFragment as part of ViewPager

Barkside’s answer works with FragmentPagerAdapter but doesn’t work with FragmentStatePagerAdapter, because it doesn’t set tags on fragments it passes to FragmentManager. With FragmentStatePagerAdapter it seems we can get by, using its instantiateItem(ViewGroup container, int position) call. It returns reference to fragment at position position. If FragmentStatePagerAdapter already holds reference to fragment in question, instantiateItem just … Read more

Custom Listview/Recyclerview

For listview you will need something like this, after populating your list: private void changeSizes() { View v; View v1; TextView tv; // this one depends on your layout TextView tv1; int count = myList.getCount(); int middleRowIndex = (int)count/2 ; TextView midRow = myList.getAdapter().getView(middleRowIndex, null, null).findViewById(R.id.textView); midRow.setTextSize(TypedValue.COMPLEX_UNIT_SP,(int)(count * middleRowIndex)); int prevIndex = middleRowIndex – 1; … Read more

android editText is not prints my input given to it

Use this i think it may be work… LinearLayout.LayoutParams param = new LinearLayout.LayoutParams (LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT, 1f); OR try this…. public View getView(int i, View view, ViewGroup viewGroup) { LinearLayout linearLayout; linearLayout = new LinearLayout(context); LinearLayout.LayoutParams param = new LinearLayout.LayoutParams (LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT, 1f); linearLayout.setOrientation(LinearLayout.VERTICAL); EditText editText = new EditText(context); editText.setMinLines(1); editText.setLayoutParams(params); linearLayout.addView(editText); return linearLayout; }