2010-11-27 5 views
2
public SomeClass(Context context, SomeType some_arg) { 
     super(context); 
     LayoutInflater inflater = (LayoutInflater)context.getSystemService(
        Context.LAYOUT_INFLATER_SERVICE); 
     inflater.inflate(R.layout.some_layout_with_button, this, true); 
     m_button=(Button)findViewById(R.id.mButton); 
     m_textView=(TextView)findViewById(R.id.mTextView); 
     m_button.setOnClickListener(new OnClickListener(){ 
       @Override 
       public void onClick(View v){ 
       //TODO 
       } 
      }); 
    } 

В деятельности, в OnCreate (...) Я написалРасширяет ViewGroup

this.setContentView(new SomeClass(getApplicationContext(),arg)); 

SomeClass продляет LinearLayout, some_layout_with_button.xml правильно Но на экране эмулятора - ничего. Зачем?

UPD:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:orientation="vertical" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content"> 
    <LinearLayout android:orientation="horizontal" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:paddingBottom="20px"> 
     <Button android:id="@+id/mButton" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="BT" /> 
     <TextView android:id="@+id/mTextView" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:textSize="16px" 
       /> 
    </LinearLayout> 
    <LinearLayout android:orientation="horizontal" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content"> 
     <RadioGroup android:id="@+id/mRadioGroup" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:orientation="horizontal"> 
      <RadioButton android:id="@+id/mRadioButton1" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_marginLeft="60px" 
        android:text="Text1"/> 
      <RadioButton android:id="@+id/mRadioButton2" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_marginLeft="60px" 
        android:text="Text2"/> 
     </RadioGroup> 
    </LinearLayout> 
</LinearLayout> 
+0

ли вы назвать `super.onCreate()`? – 2010-11-27 22:20:07

+0

да, конечно, я назвал super.onCreate (...) – 2010-11-27 22:21:55

ответ