मैं एंड्रॉइड डेवलपमेंट के लिए काफी नया हूं और बस प्राथमिकताएं आई हैं। मैंने पाया PreferenceScreenऔर इसके साथ एक लॉगिन कार्यक्षमता बनाना चाहता था। मेरे पास एकमात्र समस्या यह है कि मुझे नहीं पता कि मैं "लॉगिन" बटन को कैसे जोड़ सकता हूं PreferenceScreen।
यहाँ मेरी PreferenceScreenतरह दिखता है:
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
...
<PreferenceScreen android:title="@string/login" android:key="Login">
<EditTextPreference android:persistent="true" android:title="@string/username" android:key="Username"></EditTextPreference>
<EditTextPreference android:title="@string/password" android:persistent="true" android:password="true" android:key="Password"></EditTextPreference>
</PreferenceScreen>
...
</PreferenceScreen>
बटन दो EditTextPreferenceएस के नीचे होना चाहिए ।
क्या इस समस्या का कोई सरल समाधान है? एक समाधान जो मुझे मिला वह काम नहीं कर रहा था क्योंकि मैं उप PreferenceScreens का उपयोग करता हूं ।
अपडेट करें:
मुझे लगा कि मैं इस तरह से बटन जोड़ सकता हूं:
<PreferenceScreen android:title="@string/login" android:key="Login">
<EditTextPreference android:persistent="true" android:title="@string/username" android:key="Username"></EditTextPreference>
<EditTextPreference android:title="@string/password" android:persistent="true" android:password="true" android:key="Password"></EditTextPreference>
<Preference android:layout="@layout/loginButtons" android:key="loginButtons"></Preference>
</PreferenceScreen>
और लेआउट फ़ाइल ( loginButtons.xml) इस तरह दिखती है:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:weightSum="10"
android:baselineAligned="false" android:orientation="horizontal">
<Button android:text="Login" android:layout_width="fill_parent"
android:layout_weight="5" android:layout_height="wrap_content"
android:id="@+id/loginButton" android:layout_gravity="left"></Button>
<Button android:text="Password?" android:layout_width="fill_parent"
android:layout_weight="5" android:layout_height="wrap_content"
android:id="@+id/forgottenPasswordButton"></Button>
</LinearLayout>
तो अब बटन दिखाई देते हैं लेकिन मैं उन्हें कोड में एक्सेस नहीं कर सकता। मैंने इसके साथ प्रयास किया findViewById()लेकिन यह अशक्त है। किसी भी विचार मैं इन बटन का उपयोग कैसे कर सकता है?
android:onClick="method"प्रत्येक बटन में जोड़ें , जहां विधि गतिविधि के रूप में परिभाषित की गई है public void method(View v)।
