2011-06-20 18 views
0

1つのxmlファイルとViewを1つのアクティビティに拡張する1つのクラスを追加して、同時に動作させる必要があります。androidアクティビティに2つのビューを追加する方法

onCreate() 
{ 
RelativeLayout ll= new RelativeLayout(this); 
ll.addView(new GraphicsView(this)); 
ll.--------->how to add main.xml here? 
setContentView(ll);// so that i can write like this 
} 

この問題を解決してください以下のような 、

  1. main.xml
  2. プライベート静的クラスGraphicsViewは表示

MyActivityを拡張します。 ありがとう

答えて

2

使用レイアウトインフレータ。このようなことをしてください....

LayoutInflater inflater = (LayoutInflater) adapterContext 
         .getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
       view = inflater.inflate(R.layout.your_xmls, null); 

このビューをllに追加します。

ll.addView(表示)...

ありがとうございました。

関連する問題