2016-06-17 12 views
0

こんにちは私はフラグメントにポップアップウィンドウを追加したいと思います。誰かが私を助けてくれたら、それはすばらしいことでしょう。このフラグメントにこのpopup.xmlを追加するにはどうすればよいですか?

ここは私のフラグメントコードです。

public class Info extends Fragment { 

public Info() { 
    // Required empty public constructor 
} 

@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
} 

@Override 
public View onCreateView(LayoutInflater inflater, ViewGroup container, 
         Bundle savedInstanceState) { 
    // Inflate the layout for this fragment 
    return inflater.inflate(R.layout.info, container, false); 
} 

はここにここに私のpopup.xml

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" > 

    <ImageView 
     android:id="@+id/image" 
     android:layout_width="wrap_content" 
     android:src="@drawable/pozitif" 
     android:layout_height="wrap_content" 
     android:layout_marginRight="5dp" /> 

    <TextView 
     android:id="@+id/text" 
     android:layout_width="wrap_content" 
     android:text="dfdfdsfs" 
     android:layout_height="wrap_content" 
     android:textColor="#000000" 
     android:layout_toRightOf="@+id/image"/>/> 

    <Button 
     android:id="@+id/dialogButtonOK" 
     android:layout_width="100px" 
     android:layout_height="wrap_content" 
     android:text=" Ok " 
     android:layout_marginTop="5dp" 
     android:layout_marginRight="5dp" 
     android:layout_below="@+id/image" 
     /> 

</RelativeLayout> 

答えて

0

あなたはDialogFragmentを使用することができている私のfragment.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" > 

    <Button 
     android:id="@+id/buttonShowCustomDialog" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Show Custom Dialog" /> 

</LinearLayout> 

です。

代わりの断片とあなたの活動を延長し、DailogFragment活動のCREATEVIEW上でDialogFragment

を使用してレイアウトを膨らませる

View v = inflater.inflate(R.layout.fragment_dialog, container, false); 

は、あなたのDailogFragmentはこれを使用呼び出すには、あなたのビュー要素

TextView Message = (TextView) v.findViewById(R.id.text_view1); 

を探します

MyDialogFragment dialog = MyDialogFragment.newInstance(); 
dialog.show(getActivity().getFragmentManager(), "MyDialogFragment"); 

この詳細については、このリンクをご覧ください。
https://developer.android.com/reference/android/app/DialogFragment.html

+0

私は何も理解していません... – murty

+0

hmm。このビデオをチェックしてください。 https://www.youtube.com/watch?v=4HbcTS1bYsc –

関連する問題