Java tutorial
/* * Copyright (c) 2014 Steffen Klee * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package de.stkl.gbgvertretungsplan.fragments; import android.app.AlertDialog; import android.app.Dialog; import android.content.DialogInterface; import android.os.Bundle; import android.support.v4.app.DialogFragment; import android.text.Html; import android.text.method.LinkMovementMethod; import android.view.LayoutInflater; import android.view.View; import android.widget.TextView; import de.stkl.gbgvertretungsplan.R; /** * Created by Steffen Klee on 15.02.14. */ public class PopupDialog extends DialogFragment { String mContent; public PopupDialog() { } public PopupDialog(String content) { mContent = content; } public void setContent(String content) { mContent = content; } @Override public Dialog onCreateDialog(Bundle savedInstanceState) { if (savedInstanceState != null) mContent = savedInstanceState.getString("content", mContent); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); LayoutInflater inflater = getActivity().getLayoutInflater(); View layout = inflater.inflate(R.layout.dialog_html, null); TextView text = (TextView) layout.findViewById(R.id.text); text.setMovementMethod(LinkMovementMethod.getInstance()); text.setText(Html.fromHtml(mContent)); builder.setView(layout); builder.setPositiveButton(getString(R.string.popup_ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); return builder.create(); } @Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putString("content", mContent); } }