2016-08-28 8 views
1

どのようにプログラムでviewParentにビューを追加するのですか?私はプログラム的pulltorefreshのコンテナにビューを追加したい

<?xml version="1.0" encoding="utf-8"?> 
<android.support.design.widget.CoordinatorLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/homeCoordinatorLayout" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context=".MainActivitys.ViewPager.Fragments.Home"> 
    <com.yalantis.phoenix.PullToRefreshView 
     android:id="@+id/pull_to_refresh" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 
     <android.support.v7.widget.RecyclerView 
      android:id="@+id/fragment_dashboard_recycler" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 
     </android.support.v7.widget.RecyclerView> 
    </com.yalantis.phoenix.PullToRefreshView> 
</android.support.design.widget.CoordinatorLayout> 

以下のように私は、XMLレイアウトファイルを持って、下図のように私は私のコーディネーターにそれを追加したが、私は追加する方法がわかりませんそれは私のpulltorefresh任意のアイデアに?

CoordinatorLayout coordinatorLayout=(CoordinatorLayout)view.findViewById(R.id.homeCoordinatorLayout); 
     ImageView imageView=new ImageView(getActivity()); 
     imageView.setImageResource(R.drawable.ufo); 

答えて

0
coordinatorLayout.addView(imageView); 

編集*
あなたはここでそれを見つけることができる対象の詳細を知っているしたい場合:
公式ドキュメントを。
2. Mysamplecodeですべての種類のビューを追加する方法については、ストレート転送Tutorialを参照してください。
3.一般的な誤解を防ぐため、関連するSO answer

+0

これは質問に対する答えを提供しません。批評をしたり、著者の説明を求めるには、投稿の下にコメントを残してください。 - [レビューから](レビュー/低品質の投稿/ 13490799) –

+0

@SuhailMehta、Agree!時には私はシンプルになっています。 –

関連する問題