मेरे सार वर्ग बढ़ाया Activity
वर्ग से तीन View
रों निम्न XML टुकड़ा में वर्णित के रूप के होते हैं:सामग्री देखें बदलें गतिशील
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@drawable/bg">
<LinearLayout
android:id="@+id/top_border">
...
</LinearLayout>
<View
android:id="@+id/activity_content"
...
/>
<LinearLayout
android:id="@+id/bottom_border">
...
</LinearLayout>
</LinearLayout>
और onCreate()
विधि में मैं सामग्री को देखने के रूप में इस एक्सएमएल लेआउट निर्धारित किया है।
मैं Activity
रों जो onCreate()
ओवरराइड करने के लिए यह एक का विस्तार करने और activity_content View
शेष सीमाओं अपरिवर्तनीय वहाँ परिभाषित करना चाहते हैं।
:
abstract public class MyActivity extends Activity {
protected View mContent;
@Override
protected onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.common_layout);
initializeContent();
}
abstract void initializeContent();
}
class OneActivity extends MyActivity {
@Override
protected void initializeContent() {
mContent = View.inflate(this, R.layout.some_view, null); // i.e. concrete View (e.g. LinearLayout, FrameLayout, GridView, etc.)
}
}
लेकिन जब मैं करना तो मेरे mContent ही के रूप में यह था जब मैं MyActivity
के onCreate()
में यह परिभाषित रहते हैं।
मैं व्यू के प्रकार/सामग्री को कैसे बदल सकता हूं Activity
पर निर्भर करता है कि अग्रभूमि में क्या है?
हाय ओवरराइड नहीं कर सकते आप अच्छी तरह से क्या चाहते हैं कुछ निश्चित लेआउट और कुछ dinamyc के साथ एक टेम्पलेट है। यदि ऐसा है तो मैं आपको टुकड़ों का उपयोग करने के लिए प्रोत्साहित करता हूं। –