Click here to Skip to main content
15,886,069 members
Articles / Mobile Apps / Android

CPForAndroid and an Android Project Template

Rate me:
Please Sign up or sign in to vote.
4.76/5 (60 votes)
6 Nov 2014CPOL11 min read 99.8K   3.3K   87  
MyDroidTemplate Eclipse Project template and a Droid App for Interacting with CodeProject
/**
 *  This file is part of CPForAndroid.
 *
 *  CPForAndroid is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  CPForAndroid is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with CPForAndroid.  If not, see <http://www.gnu.org/licenses/>.
 *  
 *  See http://CPForAndroid.googlecode.com/ for the latest version.
 */

package org.android.MyDroidTemplate;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;


public class PopUpDialog {
	@SuppressWarnings("unused")
	private static final String tag = "PopUp";
	private final Context mCtx;
	private String _title = "";
	private String _msg = "";

	public PopUpDialog(Context ctx, String title, String msg) {
		super();
		this.mCtx = ctx;
		this._msg = msg;
		this._title = title;
	}
	
    DialogInterface.OnClickListener doneListener = new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    };

	public void show() {
		final LayoutInflater factory = LayoutInflater.from(mCtx);

		View dialogView = factory.inflate(R.layout.popup, null);

		innerUpdate(dialogView);

		AlertDialog.Builder adBuilder = new AlertDialog.Builder(mCtx).setTitle(
				this._title).setIcon(android.R.drawable.ic_dialog_info)
				.setView(dialogView).setPositiveButton(android.R.string.ok, doneListener);
		adBuilder.show();

	}

	private void innerUpdate(View dialogView) {
		TextView msg_text = (TextView) dialogView.findViewById(R.id.popup_text);
		// msg
		msg_text.setText(this._msg);
		msg_text.setGravity(Gravity.CENTER);
	}

}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Chief Technology Officer Earthbotics.com
United States United States
Born in Pennsylvania (USA), just north of Philadelphia. Joe has been programming since he was ten[now much older]. He is entirely self-taught programmer, & he is currently working as an IT Manager in Seattle WA. He was previously U.S. Navy Active Reservist for (SPAWAR)
In '98 was honorably discharged from the USN. He served onboard the USS Carl Vinson (94-98) He was lucky enough to drink President Clinton's leftover wine, promoted by his Captain, and flew in a plane off the flightdeck but not all at the same time. His interests, when time allows, are developing
misc apps and Artificial Intelligence proof-of-concept demos that specifically exhibits human behavior. He is a true sports-a-holic, needs plenty of caffeine, & a coding junkie. He also enjoys alternative music and a big Pearl Jam, Nirvana, new alternative music fan, and the Alison Wonderland.
He is currently working on earthboticsai.net<> which he says is fun and cool. Cool | :cool: :cheers:

Joe is an INTP[
^] personality type. Joe "sees everything in terms of how it could be improved, or what it could be turned into. INTP's live primarily inside their own minds." INTPs also can have the "greatest precision in thought and language. Can readily discern contradictions and inconsistencies. The world exists primarily to be understood. 1% of the total population" [

Comments and Discussions