You can use custom Dialog (extends Dialog).
In the next code you will show a Dialog with the scores.
First the XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#dc000000">
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/button_close_text"
android:id="@+id/button_close"
android:layout_gravity="center_horizontal"
android:textSize="20sp"
android:textStyle="bold"
android:textColor="@color/white" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/scrollView"
android:layout_gravity="center_horizontal" >
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/linear_layout">
</LinearLayout>
</ScrollView>
</LinearLayout>
The XML above is going to show a button in top, a list of elements (key - value) in the LinearLayout with id: linear_layout.
Second the Custom Dialog:
import android.app.Dialog;
import android.content.Context;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
public class CustomDialog extends Dialog {
private LinearLayout layout;
private Context mContext;
public CustomDialog(Context context) {
super(context, android.R.style.Theme_Translucent_NoTitleBar);
setContentView(R.layout.dialog_content);
setCancelable(false);
mContext = context;
Button buttonClose = (Button)findViewById(R.id.button_close);
buttonClose.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dismiss();
}
});
layout = (LinearLayout)findViewById(R.id.linear_layout);
}
public void addKeyValuePair(String key, String value) {
TextView textView_key = (TextView)getLayoutInflater().inflate(R.layout.row_key, layout, false);
TextView textView_value = (TextView)getLayoutInflater().inflate(R.layout.row_value, layout, false);
textView_key.setText(key);
textView_value.setText(value);
layout.addView(textView_key);
layout.addView(textView_value);
}
}
With the method: addKeyValuePair(String key, String value) you are going to add the scores to the dialog before show it.
You still need the XML for your key-value for each row:
row_key.xml
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="dummy_text"
android:id="@+id/row_textView_key"
android:layout_marginTop="20sp"
android:textColor="@color/white"
android:textStyle="bold"
android:textSize="30sp"
android:layout_marginLeft="20sp">
</TextView>
row_value.xml
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="dummy_value"
android:id="@+id/row_textView_value"
android:layout_marginTop="5sp"
android:layout_marginLeft="20sp"
android:textColor="@color/white"
android:textSize="30sp">
</TextView>
Under your FragmentActivity, when you want to show the scores:
CustomDialog cd = new CustomDialog(this);
cd.addKeyValuePair("key","value");
That is all.