Learn the powerful enterprise adaptable database:

Getting Started With ADABAS & Natural

Thursday, October 24, 2013

USING JAVA FOR ANDROID APPS DEVELOPMENT (BEGINNERS)

-----
1) RUN ADT
1.1) Run Android ADT Bundle (v21.0.1-543035)
1.2) Close Welcome Panel.

2) CREATE NEW PROJECT

2.1) Go to menu File/New/Android Application Project
2.2) New Android Application (Names and SDK Versions)
Application Name: Greetings
Project Name: Greetings
Package Name: com.example.greetings
Minimum Required SDK: API 8: Android 2.2 (Froyo)
Target SDK: API 17: Android 4.2 (Jelly Bean)
Compile With: API 17: Android 4.2 (Jelly Bean)
Theme: Holo Light with Dark Action Bar
2.3) New Android Application (Project Configuration)
Accept Default.
2.4) New Android Application (Launcher Icon)
2.5) New Android Application (Create Activity)
2.6) New Android Application (Activity Layout)
2.7) Done.
2.7.1) activity_main.xml is selected by default.
2.7.2) the file content is displayed in the form of Graphical Layout.

3) EDIT THE (LAYOUT) VIEW

3.1) Notice that initially the layout contains a label “Hello World!”.
3.2) Click to select the label.
Press [Delete] button to delete the label.
3.3) In the Layouts section of Palette, click and drag LinearLayout (Vertical) to the top left corner of the main layout.
3.4) Find the Outline Panel.
Notice that there is a warning icon.
If you hover your mouse over the icon, the explanation message pops up.
We will add child objects into this layout.
3.5) Find the abc Text Fields object in the Palette.
3.6) Click the object and drag it into the LinearLayout item in the Outline Panel.
3.7) Outcome:
3.8) Find the button object in the Palette.
3.9) Drag it into LinearLayout and place it under editText1 object as follows:
3.10) Your view will look like below:
3.11) Save.
3.12) Switch to activity_main.xml tab.
You should see the following codes:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity" >
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:orientation="vertical" >
        <EditText
            android:id="@+id/editText1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >
            <requestFocus />
        </EditText>
        <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Button" />
    </LinearLayout>
</RelativeLayout>
Take note of the highlighted (id) texts, i.e editText1 and button1.
Later, we will use these id names to bind Java codes to the XML layout.

4) VIEW JAVA CODES

4.1) In the Package Explorer panel, find the source file MainActivity.java.
4.2) Double-click the file name.
Notice two panels.
4.2.1) Main Panel.
4.2.2) Outline Panel.
Note: To show line numbers for code editor:
Go to menu Windows/Preferences,
Click Editors/Text Editors,
Select Show line numbers.

5) UNDERSTANDING JAVA CODES

This section assumes that you are totally new to Java Language.
5.1) The Outline Panel shows the structure of a typical Java Code File (technically called Java Class File)
The code structure is divided into 3 parts.
Part 1: Package name (written in reverse-DNS form). This is a unique name representing your project.
Part 2: Import Declarations. Think of this as code libraries from which you may import methods (functions) for your programming solutions.
  • android.app.Activity is a class used to represent a single screen with a user interface.
  • android.app.Bundle is a class used for passing data between activities.
  • android.app.Menu is a class used to provide menu options related to an application.
Part 3: The MainActivity Definition. This is where you specify what you would want the computer to do.
In the above example, you have instructions for the event onCreate and onCreateOptionsMenu, i.e.
Event onCreate = when the activity is created
Event onCreateOptionsMenu = when the OptionsMenu is created
5.2) The Main Panel shows the codes in Java Syntax.        
There are few things to learn from the codes:
  • Related codes are grouped within { } symbols. They can be nested as well.
  • Java implements object oriented programming concept. You will see a lot of dot-style notation e.g. android.os.Bundle.
  • New class (child) can be created from the existing class (parent). The child inherits the properties and methods of the parent. E.g.  MainActivity will inherit whatever properties and methods of Activity class. This promotes code-reusability.
  • The keyword “super” is used to initialize the object based on the parent’s method first.
  • If the child class would want to modify some methods inherited from the parent class, it can “override” (refer line no. 9 and 15) them with different instructions. E.g. (line no.12) setContentView with the res/layout/activity_main.xml file and  (line no.18) getMenuInflater by inflating values from res/menu/activity_main.

6) EDITING JAVA CODES

6.1) Initially, XML Layout and Java Codes are not related and thus they do not know one another. Objects in the XML Layout (e.g. editText1 and button1) must be identified first before they can be processed by Java Codes.
6.2) Let’s say we want …
the button to respond to clicks by …
popping up a message containing text entered by user in the text field.
6.3) We need the following algorithm:
(blue colour text refers to the codes in Step 6.4)
1) Bind a button object to the button layout identified by button1. (line no.13)
2) Attach an onClickListener (a method to listen for click events) method to the button. (line no.14)
3) Override the onClick (a method to respond to click events) method to the button. (line no.16)
4) Bind a text object to the text layout identified by textEdit1. (line no.17)
5) Get the input value from the text object and convert the value to a string. (line no.18)
6) Display the string value using toast object. (line no.19)
6.4) Edit the codes as follows:
6.5) Error markers appear under certain keywords that are not recognized by Java compiler. However, Eclipse has a smart debugging function that is able to suggest corrections. In this example, choose the option to import the missing class.
6.6) Repeat the same technique to the other error markers. Do it carefully and ensure that you are choosing option to import class only.
6.7) Outcome:
6.8) Run as Android Application…
6.9) Outcome:

-----

Sunday, October 13, 2013

FREE PLC ONLINE SIMULATOR




Finally, a FREE place to practice your PLC programming skills. The PLC Simulator is here to help you learn PLC programming.

For simple directions please view the help section. The help section can be found on the top menu of the PLC simulator.

Suggestions for improvement are always welcomed. If you would like to share any of the PLC programs you write via the simulator, please upload them to the downloads section of the site. You may also wish to search there for some examples other people have written.
Enjoy the program and remember that your feedback is welcomed as well as your suggestions for improvement. 

NO requested feature will be considered crazy.

Raptor Flowchart Quick Start For Beginners


Raptor Flow Chart Quick Start For Beginners
----

1) SETTING UP.

1.1) This tutorial is based on Raptor Portable. Download from here, http://raptor.martincarlisle.com/RaptorPortable_4.0_Revision_6.paf.exe
or from here,
1.2) Run the RaptorPortable paf file.
Choose English Language.
1.3) Set the install location.
1.4) Setup process done.
Select Run Raptor Portable.
Click Finish.

2) RUNNING RAPTOR FOR THE FIRST TIME.

2.1) Raptor Main Application Window.
a) Menu bar.
b) Tool bar.
c) Symbols panel.
d) Main panel.
2.2) Click the Run button, 
The main panel shows the following image sequence.
It means that the program is running from Start to End.
2.3) Another window, called MasterConsole, pops up to summarize the events.
2.4) Save your chart as “testflow”.

3) ADDING SYMBOLS TO FLOWCHART

3.1) Click the symbol Assignment and drag it to a point in between Start and Stop.
3.2) Outcome:
3.3) Double-click the red rectangle.
Enter Statement window pops up.
3.4) Type as follows:
Click Done.
3.5) Click and drag the Output symbol to a point in between Assignment and End.
3.6) Outcome:
3.7) Double-click the Output symbol.
Enter Output window pops up.
3.8) Type as follows:
As you type, you may get suggestions as follows:
a)
b)
c)
d)
3.9) Outcome:

4) GENERATING CODES.

4.1) Click Run.
4.2) Go to menu Generate/C++
4.3) Outcome:
(A text file is generated and automatically opened by Notepad)
4.4) Notice that the declaration statement ?? coins; requires you to set the data type for the variable coins, e.g int.

5) DOWNLOAD

----