Posts

Simple Notification in Android

Image
Notifications are a way to provide information to your customer which displays as a pop up on the device. It helps you to keep in touch with your customer. I am going to create a simple notification without going deep because everything is available on Google. We must understand a few concepts before going further. Notification channel:  Assume you have developed an app for an online learning center where they teach Maths and English. Students can either learn Maths, English, or Both. we must send notification related to Maths to only students who have taken Maths. In this case, we can create channels for Maths, English, and both so triggered notification will be delivered to students who have taken that subject. Each Notification channel can have a different Notification sound and different behavior that you can change from the Notification setting page. I forgot to tell you that Google has introduced the Notification channel from Android 8.0 i.e API level 26. Now yo...

Spinner in Android

spinner in android is used to give user to choose an option from drop down list which contains the options...and when you choose any option it will display that option..by default it will display first option... public class main extends Activity {     /** Called when the activity is first created. */  String [] name = {"ram","shayam","reeta","geeta","seeta"}; Context ctx;     @Override     public void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.main);         ctx =this;       Spinner spin = (Spinner)findViewById(R.id.spinner1); ArrayAdapter<String> adapter = new ArrayAdapter<String>(ctx,android.R.layout.simple_spinner_item,name); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spin.setAdapter(adapter);         ...

Custom font in android

if u want to apply custom font to your textview text or button follow the below steps.. 1. go to google n download the font and keep them inside ur assets folder. 2.suppose u want to apply custom font to ur textview text:  TextView t1 = (TextView)findViewById(R.id.txtAmount); Typeface face1 = Typeface.createFromAsset(activity.getAssets(),"Arvo-Regular.ttf"); //where Arvo-Regular.ttf referes to your font which is placed inside ur assets folder.  t1.setTypeface(face1); //it will set the font of ur textview same way u have to do it for buttons etc.. ex..                 Typeface face1 = Typeface.createFromAsset(ctx.getAssets(),"Arvo-Regular.ttf");        TextView t1 = (TextView)findViewById(R.id.txtAmount);                   t1.setTypeface(face1);

Tabs in Android

You need to use a TabHost and a TabWidget. The TabHost must be the root node for the layout, which contains both the TabWidget for displaying the tabs and a FrameLayout for displaying the tab content.TabHost allows the user to create tabs. main.xml:     <?xml version="1.0" encoding="utf-8"?> <TabHost xmlns:android="http://schemas.android.com/apk/res/android"         android:id="@android:id/tabhost" android:layout_width="fill_parent" android:layout_height="fill_parent" > <LinearLayout android:id="@+id/LinearLayout01" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/bckground" android:orientation="vertical" android:padding="5dp" > <TabWidget    android:id="@android:id/tabs"    android:layout_width="fill_parent...
Scroll Bar is a Layout container for a view hierarchy that can be scrolled by the user, allowing it to be larger than the physical display. A ScrollView is a FrameLayout, meaning you should place one child in it containing the entire contents to scroll. Note-Scroll bar must contain only one child layout    <?xml version="1.0" encoding="utf-8"?>     <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"       android:layout_width="match_parent"       android:layout_height="match_parent"       android:orientation="vertical" >       <TextView         android:id="@+id/title"         android:layout_width="fill_parent"         android:layout_height="38dp"         android:background="#96CDCD"         android:gravity="center"         android:text="...

DialogBox in Android

Using DialogBox,you can display whatewer you want., the way you want it.Suppose you want you display a dialogbox onclick of a button in your main activity. This is the layout of main activity. main.xml  <?xml version="1.0" encoding="utf-8"?>    <RelativeLayout android:id="@+id/RelativeLayout01&quot;      android:layout_width="fill_parent"      android:layout_height="fill_parent"      xmlns:android="http://schemas.android.com/apk/res/android">    <TextView android:id="@+id/TextView01"       android:layout_width="wrap_content"       android:layout_height="wrap_content"        android:text="Welcome to fafadiatech">    </TextView>    <Button android:layout_height="wrap_content"     android:layout_below="@+id/TextView01"     android:layout_width="wrap_content"     android...

SMS in Android

Sending SMS in Android ====================== SMS is one of the most used and important function in android.It can be used to share small amount of data between people.SMs can be used to send message to your friend,Increase Sales and Brand exposure,New Revenue Source for your business,Mass Alert to everyone etc. Sending SMS using Intent ======================== Using built in functionality ofAndroid,We can send SMS through Intent.    Intent sendsms = new Intent(Intent.ACTION_VIEW);    sendsms.setType("vnd.android-dir/mms-sms");    sendsms.putExtra("address", "+919912345678");    sendsms.putExtra("sms_body","hey wassuppp ?????");    startActivity(sendsms); When call startActivity() with action Intent.ACTION_VIEW, the system will start an activity to display the data to the user.Android knows based upon the specified "type"("vnd.android-dir/mms-sms") that it is meant for the built-in SMS Activity.Th...

DatePicker in Android

Using DatePicker user can set a specific date by setting the day,month and year of DatePIcker.I am going to show you an example,There will be two buttons btnset and btndisplay.When user will click on btnset it will display  a dialog box and user will select the date and after selecting date when user will click on btndisplay it will display the date previously selected by user. 1.) Create a Project DatePickerExample. 2.) Create a date_picker.xml in res/layout. 3.) Put the following code in date_picker.xml :       <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"   > <Button    android:id="@+id/btnset"    android:layout_width="wrap_content"    android:layout_height="wrap_content...