murty murty - 4 months ago 14
Android Question

I need help to make Popup in this fragment below

I have an activity.java which is contains some fragments like those below, and on one of these fragments I want to make a popup window. I tried a lot of things but all failed.

Now I am showing my code here to see if someone can help me.

Here is my fragment.java:

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.kaynaklar_info, container, false);
}


Here is my fragment xml:



<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:id="@+id/kaynaklarinfo"
android:layout_height="match_parent">


<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/scrollView3" >

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/pozitif"
android:id="@+id/infonuniciresim" />
</ScrollView>




Here is my popup xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/popup_element"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#ffffff"
android:padding="10px"
android:orientation="vertical">

<TextView
android:layout_width="wrap_content"
android:id="@+id/deneme"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="Transfering data" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="Status" />

<TextView android:id="@+id/server_status_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Awaiting answer..."
android:paddingLeft="10sp" />



Answer

The popup window in Android is called as AlertDialog and you can see how to build a custom dialog here.