I have a Settings.xml layout which has buttons, textviews,etc. I am working on changing this to use PreferenceScreens for the settings layouts. I am aware that I can't use buttons like the way we use in a LinearLayout or any other. My questions are as follows:
- Is there a way I can use the buttons, views from my settings.xml into my Preference_settings.xml?
- Is there a way to make a connection between the Settings.xml and Preference_Settings.xml?
This is my settings.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:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:orientation="vertical"
android:weightSum="10" >
<RelativeLayout
android:id="@+id/top_panel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp" >
<Button
android:id="@+id/select_flight_button"
android:layout_width="@dimen/settings_button_width"
android:layout_height="wrap_content"
android:textColor="@drawable/custom_text_color_for_buttons"
android:textSize="@dimen/button_text_size"
android:textStyle="bold" />
</RelativeLayout>
<LinearLayout
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="bottom|center_horizontal"
android:layout_weight="2.25"
android:layout_marginTop="5dp"
android:layout_marginBottom="17dp"
android:gravity="top|center_horizontal"
android:orientation="horizontal" >
<ImageButton
android:id="@+id/app_version_tablet_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:background="@color/transparent"
android:gravity="center_horizontal"
android:src="@drawable/tablet_info" />
<TextView
android:id="@+id/last_outbound_sync_timestamp"
style="@style/settings_sync_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:layout_marginTop="10dp"
android:layout_marginLeft="5dp"
android:focusable="false"
android:text="@string/last_sync_time_unknown" />
</LinearLayout>
This is my preference_settings.xml
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
android:title="Flight Selection" >
<Preference
android:title="Change Flight"
android:selectable="true"
android:key="@string/choose_flight"
android:icon="@drawable/icon_select_flight" />
<Preference
android:title="Close Flight"
android:selectable="true"
android:key="@string/close_flight_successful"
android:icon="@drawable/icon_select_flight" />
</PreferenceCategory>
<PreferenceCategory
android:title="Terminal Panel" >
<Preference
android:title="Change Terminal"
android:selectable="true"
android:icon="@drawable/icon_terminal" />
</PreferenceCategory>
<PreferenceCategory
android:title="Printer Panel" >
<Preference
android:title="Choose Printer"
android:icon="@drawable/icon_printer" />
</PreferenceCategory>
<SwitchPreference
android:title="Enable Sync" />
</PreferenceScreen>