Professional Documents
Culture Documents
mBuilder.setSmallIcon(R.drawable.notification_icon);
mBuilder.setContentTitle("Notification Alert, Click Me!");
mBuilder.setContentText("Hi, This is Android Notification Detail!");
Step 3 - Attach Actions
This is an optional part and required if you want to attach an action with the
notification. An action allows users to go directly from the notification to
an Activity in your application, where they can look at one or more events
or do further work.
The action is defined by a PendingIntent containing an Intent that starts
an Activity in your application. To associate the PendingIntent with a
gesture, call the appropriate method of NotificationCompat.Builder. For
example, if you want to start Activity when the user clicks the notification
text in the notification drawer, you add the PendingIntent by
calling setContentIntent().
request
Code
intent
flags
int:
May
be FLAG_ONE_SHOT, FLAG_NO_CREATE, FLAG_CANCEL_CU
RRENT, FLAG_UPDATE_CURRENT, or any of the flags as
supported byIntent.fillIn() to control which unspecified
parts of the intent that can be supplied when the actual
send happens.
Custom
Adapter
when
we
extends
@Override
public long getItemId(int i) {
return 0;
}
@Override
public View getView(int i, View view, ViewGroup viewGroup) {
return null;
}
In
the
above
code
snippet
we
see
the
overrided methods of BaseAdapter which are used to set the data in a list,
grid or a spinner. From there we mainly used two functions getCount() and
getView().
Lets discuss all these functions in detail:
1. getCount():
The getCount() function returns the total number of items to be displayed in
a list. It counts the value from array list size() method or an arrays length.
For example, if we have an list of elements in an arraylist and we have to
display the items in a list view then we can count the total number of
elements using the size function and then that integer value is returned by
the function getCount() as shown below.
@Override
public int getCount() {
int count=arrayList.size(); //counts the total number of elements from the
arrayList
return count;//returns the total count to adapter
}
2. getView(int i, View view, ViewGroup viewGroup):
This function is automatically called when the list item view is ready to be
displayed or about to be displayed. In this function we set the layout for list
items using LayoutInflater class and then add the data to the views
like ImageView, TextView etc.
Below is the getView functions example code with explanation included in
which we set the layout using LayoutInflater and then get the views id and
implement them.
@Override
public View getView(int i, View view, ViewGroup viewGroup) {
view = inflter.inflate(R.layout.activity_gridview,
displaying items
null);//set
layout
for