I'm using ListView with CheckedTextView elemenets to show checklist.
And it works well on 2 phones i tried (Both KitKat), but i have problem on device called RuggedPad (link), which also has Android 4.1.1
Problem is that instead of list, it is showing some kind of bitmap(?) - effect is that you if u scroll it overlaps itself(screenshots attached), and is not checkable.
Tried to redraw listActivity on scroll :
@Override
public void onScroll(AbsListView view, int firstVisibleItem,int visibleItemCount, int totalItemCount) {
getListView().invalidate();
getListView().invalidateViews();
getListView().requestLayout();
}
Also tried to disable drawing cache:
getListView().setDrawingCacheEnabled(false);
Still does nothing.
Here is my code creating ListView:
@Override
protected void onCreate(Bundle savedInstanceState) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
super.onCreate(savedInstanceState);
Intent intent = getIntent();
type = intent.getStringExtra(KEY_TYPE);
String breakdown = intent.getStringExtra(KEY_DATA);
try {
JSONData = new ArrayList<Model>();
JSONArray breakdownJSON = new JSONArray(breakdown);
for (int i = 0; i < breakdownJSON.length(); i++) {
JSONData.add(new Model(breakdownJSON.getJSONObject(i)));
}
} catch (Exception e) {
finish();
}
adapter = new ArrayAdapter<Model>(this, R.layout.action_list, JSONData) {
public long getItemId(int position) {
return position;
}
};
setListAdapter(adapter);
getListView().requestFocusFromTouch();
getListView().setOnScrollListener(this);
getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
for (int i = 0; i < JSONData.size(); i++) {
getListView().setItemChecked(i, JSONData.get(i).checked);
}
getListView().setDrawingCacheEnabled(false);
}
And .xml row definition:
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/action_list_textview"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeightSmall"
android:textAppearance="?android:attr/textAppearanceListItemSmall"
android:gravity="center_vertical"
android:checkMark="?android:attr/listChoiceIndicatorMultiple"
android:textSize="22sp"
/>
Thanks for any help.
I found reason after couple of hours.
Problem was in "android:theme" field for that activity:
android:theme="@style/FullscreenTheme"
was causing all the problem.