Sunday 15 March 2015

Fullscreen Android Preference -



Fullscreen Android Preference -

problem

i'm trying create custom preference takes entire height of current preferencescreen. preference conceptually similar wi-fi selection screen. asynchronously loads info , adds listview of possible options. consistent wi-fi screen i'd preference launch standalone preference activity takes entire screen. don't want utilize dialog listpreference since info loaded asynchronously , wouldn't consistent wi-fi screen.

approach 1

my first approach used preferencefragment load preferencescreen had single kid preference. has notable issue custom preference shoved single list view option:

my preference getting cutting off because preferencescreen letting take tiny portion of screen. looks preferencescreen launches single activity listview inflates preferencescreen's kid preferences. tried subclassing preferencescreen alter how listview displays custom preference; however, appears preferencescreen final. unable manipulate height of custom preference preference's xml or java code. able increment height partially next suggestion found in this post; however, never take entire screen real estate. here's current xml preference's view:

<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/widget_frame" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:paddingleft="16dp" android:layout_centerinparent="true"> <listview android:id="@+id/server_list" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="center_horizontal"/> </relativelayout>

approach 2

my next approach created custom activity inflated views how wanted. problem here wasn't able figure out how tie in custom view straight preference system. looks both preferenceactivity , preferencefragment want inflate hierarchy that's rooted preferencescreen. seems no matter i'll run problems seen in approach 1 if seek utilize that. means way save preference info going involve manually saving, loading, , manipulating user preference info when activity starts, exits, etc. seems pretty poor alternative because i'm creating worse version of existing preferenceactivity , preferencefragment classes.

that beingness said, preference going save 3 discrete key-value pairs though user ends making single selection. situation may different plenty merit me rolling own custom code.

future direction

figure out how adjust height of custom preference in approach 1 forcefulness take available screen real estate figure out how utilize preference scheme without manually handling of stuff preferenceactivity , preferencefragment handle you. accept situation different plenty merit rolling own code save , load 3 key-value pairs of settings using approach 2

android android-fragments android-listview android-preferences android-listfragment

No comments:

Post a Comment