android: Fix display of remediation instructions with support library

Because the support library creates its own layout manually and uses
different IDs than the list_content layout we can't use the method we
used previously (and which is actually recommended in the docs).
This commit is contained in:
Tobias Brunner 2016-04-28 17:00:27 +02:00
parent 7c5fec3a5a
commit 353526601a
2 changed files with 15 additions and 8 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2013 Tobias Brunner
* Copyright (C) 2013-2016 Tobias Brunner
* Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
@ -15,17 +15,18 @@
package org.strongswan.android.ui;
import org.strongswan.android.R;
import org.strongswan.android.logic.imc.RemediationInstruction;
import android.os.Bundle;
import android.support.v4.app.ListFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.FrameLayout;
import android.widget.TextView;
import org.strongswan.android.R;
import org.strongswan.android.logic.imc.RemediationInstruction;
public class RemediationInstructionFragment extends ListFragment
{
public static final String ARG_REMEDIATION_INSTRUCTION = "instruction";
@ -37,7 +38,13 @@ public class RemediationInstructionFragment extends ListFragment
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
return inflater.inflate(R.layout.remediation_instruction, container, false);
/* while the documentation recommends to include "@android:layout/list_content" to retain
* the default functionality, this does not actually work with the ListFragment provided by
* the support library as it builds the view manually and uses different IDs */
View layout = inflater.inflate(R.layout.remediation_instruction, container, false);
FrameLayout list = (FrameLayout)layout.findViewById(R.id.list_container);
list.addView(super.onCreateView(inflater, list, savedInstanceState));
return layout;
}
@Override

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2013 Tobias Brunner
Copyright (C) 2013-2016 Tobias Brunner
Hochschule fuer Technik Rapperswil
This program is free software; you can redistribute it and/or modify it
@ -45,8 +45,8 @@
android:textIsSelectable="true"
android:textAppearance="?android:attr/textAppearanceMedium" />
<include
layout="@android:layout/list_content"
<FrameLayout
android:id="@+id/list_container"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"