ad728

Monday, October 10, 2016

AIDE Tutorial - 26 Simple Notification

Main.xml


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center">
    <Button
android:onClick="show"
        android:text="Click here"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
</LinearLayout>
MainActivity.java

package com.kc.simplenotification;
import android.app.*;
import android.os.*;
import android.view.*;
import android.content.*;
public class MainActivity extends Activity
{
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }

public void show (View v){
Notification.Builder nb=
new Notification.Builder(this);
nb.setContentTitle("Notification");
nb.setContentText("You Clicked!!!!");
nb.setSmallIcon(R.drawable.ic_launcher);


NotificationManager nm=(NotificationManager)
getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(1,nb.build());
}
}

Watch Video

Share:

AIDE Tutorial - 26.3 In Progress Notification

Main.Xml


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center">
    <Button
android:onClick="abc"
        android:text="Download"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
</LinearLayout>
MainActivity.java

package com.kc.inprogressnotif;
import android.app.*;
import android.os.*;
import android.view.*;
import android.content.*;
public class MainActivity extends Activity
{
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }

public void abc(View v){
Notification.Builder nb=new Notification.Builder(this);
nb.setContentTitle("Notification");
nb.setContentText("Download in progress");
nb.setSmallIcon(R.drawable.ic_launcher);
nb.setProgress(100,90,false);

NotificationManager nm=(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(1,nb.build());
}
}


Share:

AIDE Tutorial - 26.4 Expandable Notification

Main.xml


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center">
    <Button
android:onClick="show"
        android:text="Click here"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
</LinearLayout>

MainActivity.java
package com.kc.ExpandableNotification;
import android.app.*;
import android.os.*;
import android.view.*;
import android.content.*;
public class MainActivity extends Activity
{
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
public void show (View v){
Notification.Builder nb=new Notification.Builder(this);
nb.setContentTitle("Notification");
nb.setContentText("Downloaded");
nb.setSmallIcon(R.drawable.ic_launcher);

Notification.InboxStyle nis=new Notification.InboxStyle();
nis.setBigContentTitle("Downloaded part");
nis.addLine("Part 1");
nis.addLine("Part 2");
nis.addLine("Part 3");
nis.addLine("Part 4");
nis.addLine("Part 5");
nis.addLine("Part 6");
nis.addLine("Part 7");
nis.addLine("Part 8");
nb.setStyle(nis);


NotificationManager nm=(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(1,nb.build());
}
}



Share:

AIDE Tutorial - 26.1 Updating Notification

Main.Xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center">
    <Button
android:onClick="show"
        android:text="Click here"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
</LinearLayout>
MainActivity.java

package com.kc.UpdatingNotification;
import android.app.*;
import android.os.*;
import android.view.*;
import android.content.*;
public class MainActivity extends Activity
{
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
int count=0;



public void show (View v){
count++;
Notification.Builder nb= new Notification.Builder(this);
nb.setContentTitle("My Notification");
nb.setContentText("You clicked!!! "+count+" times");
nb.setSmallIcon(R.drawable.ic_launcher);

NotificationManager nm=(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(1,nb.build());
}
}


Share:

AIDE Tutorial - 26.2 Multiple Notification

Main.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center">
    <Button
android:onClick="click"
        android:text="Click here"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
</LinearLayout>
MainActivity.java

package com.kc.MultipleNotification;
import android.app.*;
import android.os.*;
import android.view.*;
import android.content.*;
public class MainActivity extends Activity
{
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }


int in;
public void click (View v){
in++;
Notification.Builder nb= new Notification.Builder(this);
nb.setContentTitle("My Notification");
nb.setContentText("You Clicked!!!");
nb.setSmallIcon(R.drawable.ic_launcher);
NotificationManager nm=(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(in,nb.build());
}
}


Share:

AIDE Tutorial - 25 Search Dialog

Main.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
    <SearchView
android:id="@+id/mainSearchView"
        android:queryHint="Search your country"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" />
<ListView
android:id="@+id/mainListView"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" />
</LinearLayout>
Java

package com.kc.searchdialog;
import android.app.*;
import android.os.*;
import android.widget.*;
import android.widget.SearchView.*;
public class MainActivity extends Activity
{
ArrayAdapter <String> ad;
String country[]={
"USA","UK", "Nepal", "UAE",
"China","Bangladesh", "India", "Japan",
"Korea","Russia", "Bhutan", "Afganistan",
"Pakistan","Australia",
};


    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

ad=new ArrayAdapter<String>(
this,
android.R.layout.simple_expandable_list_item_1,country);

ListView lll=(ListView)findViewById(R.id.mainListView);
SearchView sss=(SearchView)findViewById(R.id.mainSearchView);

lll.setAdapter(ad);
sss.setOnQueryTextListener(new OnQueryTextListener(){
@Override
public boolean onQueryTextSubmit(String p1)
{
// TODO: Implement this method
return false;
}
@Override
public boolean onQueryTextChange(String ppp)
{
ad.getFilter().filter(ppp);
// TODO: Implement this method
return false;
}
});
    }
}


Share:

AIDE Tutorial 24 TabHost

Main xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="top">
    <TabHost android:id="@+id/th"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TabWidget android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<FrameLayout android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/one"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:text="android smartphone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:id="@+id/two"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:text="apple smartphone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:id="@+id/three"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</FrameLayout>
</LinearLayout>
</TabHost>
</LinearLayout>
Java

package com.mycompany.tb;
import android.app.*;
import android.os.*;
import android.widget.*;

public class MainActivity extends Activity
{
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
  
TabHost th=(TabHost)findViewById(R.id.th);
th.setup();



TabHost.TabSpec sp=th.newTabSpec("");
sp.setContent(R.id.one);
sp.setIndicator("Android");
th.addTab(sp);

sp=th.newTabSpec("");
sp.setContent(R.id.two);
sp.setIndicator("iphone");
th.addTab(sp);

sp=th.newTabSpec("");
sp.setContent(R.id.three);
sp.setIndicator("myphone");
th.addTab(sp);
   }
}


Share:

Total Pageviews

Sponsor

Sponsor

ad300