Posts

Showing posts from September, 2018

Sun Sep 30 23:02:46 PDT 2018

Image
AChartEngine is now the most widely used jar in the world to draw various types of following charts.             1. Graphical chart             2. Line chart             3. Bar chart             4. Scatter chart             5. Time chart             6. Pie chart This article is about draw pie chart using achartengine. Sample screen shot of pie chart drawn using achartengine. This pie chart has the following options.         1. Movable         2. Zoomable         3. Clickable To draw this chart first you have to import achartengine  jar into your project folder. If you are using eclipse  then right click on your project --> Build Path --> Configure Build Path --> Libraries tab --> Add External JARs. This is the way to import external jars into our project. Coding: main.xml &ltLinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="

Sun Sep 30 22:02:46 PDT 2018

Image
Simple Pie Chart example without using any external jar in android. Here We are creating chart using Canvas class in android. This is the sample screenshot of our application.  And this is also sample screenshot of our application. It is easy to draw this chart in android. First our xml will be. &lt?xml version="1.0" encoding="utf-8"?&gt &ltRelativeLayout 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" &gt &ltLinearLayout android:id="@+id/linear" android:layout_width="match_parent" android:layout_height="match_parent" &gt &lt/LinearLayout&gt &lt/RelativeLayout&gt Our Activity will be. public class MainActivity extends Activity { float values[] = { 700, 400, 100, 500,600 }; @Overri?

Sun Sep 30 20:02:41 PDT 2018

Best Timer example for android Timer t = new Timer(); TimerTask task = new TimerTask() { @Override public void run() { runOnUiThread(new Runnable() { @Override public void run() { TextView tv1 = (TextView) findViewById(R.id.timer); tv1.setText(time + ""); if (time > 0) time -= 1; else tv1.setText("Welcome"); } }); } }; t.scheduleAtFixedRate(task, 0, 1000);

Sun Sep 30 19:03:15 PDT 2018

Image
db4o is a Object oriented database. This tutorial was written to get you started with db4o as quickly as possible. Before you start, please make sure that you have downloaded the latest db4o distribution from the db4objects website . In this tutorial I have used db4o-8.0.184.15484-all-java5.jar from dropbox.com Then kindly put the file in your project's lib folder and configure project's Build Path . Enough, Let us start !!! 1. Create a class to configure db4o. I named it as Db4oHelper. Code: Db4oHelper.java import java.io.IOException; import android.content.Context; import android.util.Log; import com.db4o.Db4oEmbedded; import com.db4o.ObjectContainer; import com.db4o.config.EmbeddedConfiguration; public class Db4oHelper { private static ObjectContainer oc = null; private Context context; /** * @param ctx */ public Db4oHelper(Context ctx) { context = ctx; } /** * Create, open and close the database */ public ObjectContainer d

Sun Sep 30 18:02:42 PDT 2018

This Handler will hide the textview in a few seconds later. public Handler () Since : API level 1 Default constructor associates this handler with the queue for the current thread. If there isn't one, this handler won't be able to receive messages. Define a runnable variable with your code. Runnable hide = new Runnable() { @Override public void run() { // TODO Auto-generated method stub textview.setVisibility(View.INVISIBLE); } }; public final boolean postDelayed (Runnable r, long delayMillis) Since: API Level 1 Parameters r                      The Runnable that will be executed. delayMillis      The delay (in milliseconds) until the Runnable will be executed. Returns             Returns true if the Runnable was successfully placed in to the message queue. Returns false on failure, usually because the looper processing the message queue is exiting. Note that a result of true does not mean the Runnable will be processed

Sun Sep 30 17:02:41 PDT 2018

This Handler will hide the textview in a few seconds later. public Handler () Since : API level 1 Default constructor associates this handler with the queue for the current thread. If there isn't one, this handler won't be able to receive messages. Define a runnable variable with your code. Runnable hide = new Runnable() { @Override public void run() { // TODO Auto-generated method stub textview.setVisibility(View.INVISIBLE); } }; public final boolean postDelayed (Runnable r, long delayMillis) Since: API Level 1 Parameters r                      The Runnable that will be executed. delayMillis      The delay (in milliseconds) until the Runnable will be executed. Returns             Returns true if the Runnable was successfully placed in to the message queue. Returns false on failure, usually because the looper processing the message queue is exiting. Note that a result of true does not mean the Runnable will be processed

Sun Sep 30 16:02:42 PDT 2018

Image
Good morning to all, Those who all tried RecyclerView adapter with CheckBox, you all may find the issue on dynamic data change in RecyclerView. This will help you to resolve the issue in very simple way. Video output of this project So how to achieve this task effectively? Simple, I hope you all tried with list objects only. Surely this object will have the boolean variable to know whether this object is selected or not. So now while we are select one object with the help of recyclerview and scroll down and up recyclerview adapter, the checked checkbox's position may change, this reflects on our object also, So how to avaid this issue. simple, In our recyclerview adapter's onBindViewHolder method, first set the checkedOnChangeListener of checkbox to null, and then set whether this object is selected or not to checkbox, and then add the checkedOnChangeListener to the checkbox. That's all. Issue solved. onBindViewHolder will be look like @

Sun Sep 30 15:02:41 PDT 2018

Image
Good morning to all, Those who all tried RecyclerView adapter with CheckBox, you all may find the issue on dynamic data change in RecyclerView. This will help you to resolve the issue in very simple way. Video output of this project So how to achieve this task effectively? Simple, I hope you all tried with list objects only. Surely this object will have the boolean variable to know whether this object is selected or not. So now while we are select one object with the help of recyclerview and scroll down and up recyclerview adapter, the checked checkbox's position may change, this reflects on our object also, So how to avaid this issue. simple, In our recyclerview adapter's onBindViewHolder method, first set the checkedOnChangeListener of checkbox to null, and then set whether this object is selected or not to checkbox, and then add the checkedOnChangeListener to the checkbox. That's all. Issue solved. onBindViewHolder will be look like @

Sun Sep 30 14:02:41 PDT 2018

Image
Good morning to all, Those who all tried RecyclerView adapter with CheckBox, you all may find the issue on dynamic data change in RecyclerView. This will help you to resolve the issue in very simple way. Video output of this project So how to achieve this task effectively? Simple, I hope you all tried with list objects only. Surely this object will have the boolean variable to know whether this object is selected or not. So now while we are select one object with the help of recyclerview and scroll down and up recyclerview adapter, the checked checkbox's position may change, this reflects on our object also, So how to avaid this issue. simple, In our recyclerview adapter's onBindViewHolder method, first set the checkedOnChangeListener of checkbox to null, and then set whether this object is selected or not to checkbox, and then add the checkedOnChangeListener to the checkbox. That's all. Issue solved. onBindViewHolder will be look like @

Sun Sep 30 13:02:42 PDT 2018

Image
Good morning to all, Those who all tried RecyclerView adapter with CheckBox, you all may find the issue on dynamic data change in RecyclerView. This will help you to resolve the issue in very simple way. Video output of this project So how to achieve this task effectively? Simple, I hope you all tried with list objects only. Surely this object will have the boolean variable to know whether this object is selected or not. So now while we are select one object with the help of recyclerview and scroll down and up recyclerview adapter, the checked checkbox's position may change, this reflects on our object also, So how to avaid this issue. simple, In our recyclerview adapter's onBindViewHolder method, first set the checkedOnChangeListener of checkbox to null, and then set whether this object is selected or not to checkbox, and then add the checkedOnChangeListener to the checkbox. That's all. Issue solved. onBindViewHolder will be look like @

Sun Sep 30 12:02:42 PDT 2018

Image
Good morning to all, Those who all tried RecyclerView adapter with CheckBox, you all may find the issue on dynamic data change in RecyclerView. This will help you to resolve the issue in very simple way. Video output of this project So how to achieve this task effectively? Simple, I hope you all tried with list objects only. Surely this object will have the boolean variable to know whether this object is selected or not. So now while we are select one object with the help of recyclerview and scroll down and up recyclerview adapter, the checked checkbox's position may change, this reflects on our object also, So how to avaid this issue. simple, In our recyclerview adapter's onBindViewHolder method, first set the checkedOnChangeListener of checkbox to null, and then set whether this object is selected or not to checkbox, and then add the checkedOnChangeListener to the checkbox. That's all. Issue solved. onBindViewHolder will be look like @

Sun Sep 30 11:02:49 PDT 2018

Best Timer example for android Timer t = new Timer(); TimerTask task = new TimerTask() { @Override public void run() { runOnUiThread(new Runnable() { @Override public void run() { TextView tv1 = (TextView) findViewById(R.id.timer); tv1.setText(time + ""); if (time > 0) time -= 1; else tv1.setText("Welcome"); } }); } }; t.scheduleAtFixedRate(task, 0, 1000); TimerActivity.java package com.android.timer; import java.util.Timer; import java.util.TimerTask; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.TextView; public class TimerActivity extends Activity { int time = 20; Timer t; TimerTask task; Button start; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.lay

Sun Sep 30 10:02:42 PDT 2018

Best Timer example for android Timer t = new Timer(); TimerTask task = new TimerTask() { @Override public void run() { runOnUiThread(new Runnable() { @Override public void run() { TextView tv1 = (TextView) findViewById(R.id.timer); tv1.setText(time + ""); if (time > 0) time -= 1; else tv1.setText("Welcome"); } }); } }; t.scheduleAtFixedRate(task, 0, 1000); TimerActivity.java package com.android.timer; import java.util.Timer; import java.util.TimerTask; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.TextView; public class TimerActivity extends Activity { int time = 20; Timer t; TimerTask task; Button start; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.lay

Sun Sep 30 09:02:46 PDT 2018

Best Timer example for android Timer t = new Timer(); TimerTask task = new TimerTask() { @Override public void run() { runOnUiThread(new Runnable() { @Override public void run() { TextView tv1 = (TextView) findViewById(R.id.timer); tv1.setText(time + ""); if (time > 0) time -= 1; else tv1.setText("Welcome"); } }); } }; t.scheduleAtFixedRate(task, 0, 1000); TimerActivity.java package com.android.timer; import java.util.Timer; import java.util.TimerTask; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.TextView; public class TimerActivity extends Activity { int time = 20; Timer t; TimerTask task; Button start; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.lay

Sun Sep 30 08:02:41 PDT 2018

Best Timer example for android Timer t = new Timer(); TimerTask task = new TimerTask() { @Override public void run() { runOnUiThread(new Runnable() { @Override public void run() { TextView tv1 = (TextView) findViewById(R.id.timer); tv1.setText(time + ""); if (time > 0) time -= 1; else tv1.setText("Welcome"); } }); } }; t.scheduleAtFixedRate(task, 0, 1000); TimerActivity.java package com.android.timer; import java.util.Timer; import java.util.TimerTask; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.TextView; public class TimerActivity extends Activity { int time = 20; Timer t; TimerTask task; Button start; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.lay

Sun Sep 30 07:02:41 PDT 2018

Image
Video Output: Source code link is added below. Here we have a class called MultiSelectionSpinner . In this class we have following methods. public void setItems(String[] items) Used to set adapter items using array of strings to this spinner. public void setItems(List items) Used to set adapter items using list of strings to this spinner. public void setSelection(String[] selection) Used to set selected items on this adapter using array of strings to this spinner. public void setSelection(List selection) Used to set selected items on this adapter using list of strings to this spinner. public void setSelection(int index) Used to set single selected item using position to this spinner. public void setSelection(int[] selectedIndices) Used to set selected items using array of integers to this spinner. public List

Sun Sep 30 06:02:41 PDT 2018

Image
Video Output: Source code link is added below. Here we have a class called MultiSelectionSpinner . In this class we have following methods. public void setItems(String[] items) Used to set adapter items using array of strings to this spinner. public void setItems(List items) Used to set adapter items using list of strings to this spinner. public void setSelection(String[] selection) Used to set selected items on this adapter using array of strings to this spinner. public void setSelection(List selection) Used to set selected items on this adapter using list of strings to this spinner. public void setSelection(int index) Used to set single selected item using position to this spinner. public void setSelection(int[] selectedIndices) Used to set selected items using array of integers to this spinner. public List