This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PDO | |
It allows developers to create code which is portable across many databases and platforms. In simple words it makes application independent from the data source. We can connect our application with any database like mysql, oracle etc. without make any change in our PHP code. | |
Front-End-> PHP Code(Middleware) ->PDO->Data Source(Back-end) | |
It work like layer between middleware and back-end. | |
---------------------------------------------------------------------------------------------------------------------------------- | |
Creating Connection – | |
Create object of PDO and make connection between PHP and data source. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Passing Data from one activity to other | |
Use following code in first activity | |
Intent intent=new Intent(Main.this,second.class); | |
Intent.putExtra(“val”, t1.getText().toString()); //parameter, value | |
startActivity(intent) | |
putExtra() – It is used to store parameter with value in intent. | |
Write following code in second activity | |
TextView tv=(TextView) findViewById(R.layout.tv1); | |
Tv.setText(getIntent().getExtras().getString(“val”)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Alert Dialog | |
If you want to ask the user about taking a decision between yes or no in response of any particular action taken by the user, you can use Alert Dialog. | |
Steps | |
Create the object of DialogBuilder and set operations | |
AlertDialog.Builder alertbuilder=new AlertDialog.Builder(MainActivity.this); | |
alertbuilder.setMessage("Do you want to continue...."); | |
alertbuilder.setPositiveButton("YES", new op1()); | |
alertbuilder.setNegativeButton("NO", new op2()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Custom Dialog | |
Create a Dialog | |
Dialog d=new Dialog(MainActivity.this); | |
Set Following Properties | |
Dialog d=new Dialog(MainActivity.this); | |
d.setContentView(R.layout.dialog); | |
d.setTitle("Important Message...."); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Input Dialog | |
Create layout file inputdialog.xml | |
<?xml version="1.0" encoding="utf-8"?> | |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
android:id="@+id/layout_root" | |
android:layout_width="fill_parent" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Playing and Stopping Sound – | |
• Create a folder raw in res | |
• Copy some songs in raw folder (all file names must be in small letters) | |
• Create a radio button group | |
<RadioGroup | |
android:id="@+id/rmusic" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" > | |
</RadioGroup> | |
• Add some radio buttons |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Setting wallpaper - | |
• Copy some images in folder drawable-hdpi like a.jpg, b.jpg etc. | |
• add following controls to layout | |
o ImageView1(width-200dp, height=200dp) | |
o Button1 | |
o Add scroll view and linear layout | |
<HorizontalScrollView | |
android:layout_width="200dp" | |
android:layout_height="wrap_content" | |
android:layout_gravity="center"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Using Image Gallery of Phone | |
1. Start Emulator | |
2. Open DDMS | |
3. Push images to sdcard | |
Storagesdcardpictures | |
Find push button on title bar of DDMS | |
4. Create UI | |
<RelativeLayout | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" > |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Using ListView control | |
ListView control allows us to manipulate each record which in the list. It provides index number to each item of list starting from 0. | |
Steps | |
Add ListView control to layout | |
<ListView | |
android:id="@+id/listView1" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" > | |
</ListView> | |
Create the string array of items to be added |
OlderNewer