Posts

Showing posts with the label java

Android Popup box/Dialog box code example - Java

Image
When Developing an Android application, sometimes you want to have confirmation on the action done by the user. Using a popup box or dialog box will help to get the user's intention on what are they doing.  Here is the sample code to use the popup box/dialog box to show a message to the user.  Full Code example. import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; import android.content.DialogInterface; import android.os.Bundle; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } @Override public void onBackPressed(){ ShowMessageExit("Are You Sure You Want To Quit?"); } private void ShowMessageExit(String Message){ new AlertDialog.Builder(this) .setMessage(Message) .setPositiveButton(android.R.str

How to create DataGrid or GridView in JSP - Servlet

Image
Hi there, today I will like to share my knowledge on creating basic Datagrid in JSP. This is my solution but not a permanent solution in all other cases. Maybe you can enhance this code to achieve your own objective. In this tutorial, I will use basic servlet and JSP. Note: In this tutorial, I will use this library:- MySQL JDBC Driver JSTL 1.1 the project will run on source JDK 7 This is the database table DROP TABLE IF EXISTS `blogtest`.`usersprofile`; CREATE TABLE  `blogtest`.`usersprofile` (   `userid` varchar(30) NOT NULL,   `firstName` varchar(45) NOT NULL,   `lastName` varchar(45) NOT NULL,   `emailAddress` varchar(45) NOT NULL,   PRIMARY KEY (`userid`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; INSERT INTO `usersprofile` VALUES ('Ahmad','Ahmad','Ahmad','Ahmad@gmail.com'), ('Ahmad1','Ahmad1','Ahmad1','Ahmad1@gmail.com'), ('Ahmad10','Ahmad10','Ahmad10','Ahmad10@gmail.com'), ('Ahmad11&#

Example code on how to open dialog box when click on the list AdapterView - Android

Image
Today I want to show how to open list items in the dialog box. For this tutorial, you need to have:- Dialog design view_item.xml MyDialogFragment.java class OnClick Event to call dialog. Announcement.java Class AnnouncementHelper Class OnCreateView Method view_item.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" > <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="match_parent" android:orientation="horizontal" android:padding="5dip" android:id="@+id/Announcement" android:transitionGroup="false"> <ImageView android:id="@+id/icon" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alig

how to select date time using calendar android

Image
This tutorial shows how to set date time in android app when you click on the textbox. Note : This example using Andorid Studio to create project. Im using Sample Blank Activity with Fragment sample. Step By Step  Add One EditText on the fragment Create DateTimeFragment.java class Copy Paste DateTimeFragment.java class below. Override onViewCreated event from fragment Done. Full Source Code of MainActivity class + Fragment / placeholder class package com.test.selectdatetime; import android.app.Dialog; import android.content.Context; import android.support.annotation.Nullable; import android.support.v4.app.DialogFragment; import android.support.v7.app.ActionBarActivity; import android.support.v4.app.Fragment; import android.os.Bundle; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.view.inputmethod.InputMethodManager; import android.widget.Edi