यह संभव है, इसएंड्रॉइड, एक्सएमएल में चेकबॉक्स श्रोता?
XML जैसी चीजें करने के लिए:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/addContactButton"
android:text="@string/addContactButtonLabel"
android:onClick="launchContactAdder"/><!-- here -->
</LinearLayout>
जावा:
public void launchContactAdder(View v)
{
Intent i = new Intent(this, ContactAdder.class);
startActivity(i);
}
लेकिन एक आवश्यकता है, कि विधि सार्वजनिक, शून्य और सबसे महत्वपूर्ण लेना चाहिए एक तर्क के रूप में देखें।
अब मैं बिल्कुल वही काम करना चाहता हूं लेकिन चेकबॉक्स बटन के साथ। चेकबॉक्स में एंड्रॉइड है: ऑनक्लिक विशेषता, लेकिन एंड्रॉइड ट्यूटोरियल में (http://developer.android.com/resources/samples/ContactManager/index.html) मैं यह कोड
showInvisibleControl.setOnCheckedChangeListener(new OnCheckedChangeListener()
{
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
{
Log.d(TAG, "mShowInvisibleControl changed: " + isChecked);
showInvisible = isChecked;
populateContactList();
}
});
देख सकता हूं तो एक ऑन चेक किए गए चेंज (कंपाउंड बटन बटन देखें, बूलियन चेक किया गया है) विधि। एक्सएमएल द्वारा ऐसा करने का कोई तरीका है? कोई एंड्रॉइड नहीं है: चेक किए गए चेंज विशेषता, केवल एंड्रॉइड: ऑनक्लिक विशेषता, लेकिन जैसा कि मैंने ऊपर लिखा है, उस विशेषता के नाम में संबंधित विधि नाम होना चाहिए, जो तर्क के रूप में देखें, लेकिन ऊपर दिए गए कोड से मैं समझता हूं कि मेरे पास एक विधि होनी चाहिए कंपाउंडबटन और बुलियन तर्क।
"एक्सएमएल मार्ग" में ऐसा करने का कोई तरीका?