Thursday, February 7, 2013
Dynamic gradient in android
Step One:- create a class
import android.graphics.drawable.GradientDrawable;
public class DrawableGradient extends GradientDrawable {
public DrawableGradient(int[] colors, int cornerRadius) {
super(GradientDrawable.Orientation.BR_TL, colors);
try {
this.setShape(GradientDrawable.RECTANGLE);
this.setGradientType(GradientDrawable.RECTANGLE);
this.setCornerRadius(cornerRadius);
} catch (Exception e) {
e.printStackTrace();
}
}
public DrawableGradient SetTransparency(int transparencyPercent) {
this.setAlpha(255 - ((255 * transparencyPercent) / 100));
return this;
}
}
step 2 : use this
TextView.setBackgroundDrawable(new DrawableGradient(new int[] {
0xFFFF0000, 0xFF800000, 0xFF000000 }, 0).SetTransparency(10));
email validation in android
protected final Pattern EMAIL_ADDRESS_PATTERN = Pattern
.compile("[a-zA-Z0-9\\+\\.\\_\\%\\-\\+]{1,256}" + "\\@"
+ "[a-zA-Z0-9][a-zA-Z0-9\\-]{0,64}" + "(" + "\\."
+ "[a-zA-Z0-9][a-zA-Z0-9\\-]{0,25}" + ")+");
/**
* for email validation
*
* @param str
* = string for validation
* @return true if validation is correct
*/
public boolean emailValidation(String str) {
if (str.equals("")
|| EMAIL_ADDRESS_PATTERN.matcher(str).matches() == false)
return false;
else
return true;
}
Android Custom Calendar
Android Custom Calendar
import java.text.DateFormatSymbols;
import java.text.Format;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
/**
* @author Sudhi.S
*
*/
public class UDSCalender extends Dialog implements
android.view.View.OnClickListener {
private TextView txt1 = null;
private TextView txt = null;
private GridView gd = null;
private Calendar calendar = null;
public UDSCalender(Context context) {
super(context, android.R.style.Theme_Panel);
calendar = Calendar.getInstance();
LinearLayout mreal = new LinearLayout(getContext());
LinearLayout.LayoutParams mrealp = new LinearLayout.LayoutParams(-1, -2);
mreal.setBackgroundResource(R.drawable.abs__dialog_full_holo_light);
mreal.setOrientation(LinearLayout.VERTICAL);
View vo = new View(getContext());
vo.setBackgroundColor(Color.parseColor("#ffffbb33"));
vo.setLayoutParams(new LinearLayout.LayoutParams(-1, 2));
mreal.addView(vo);
TextView txt = new TextView(getContext());
txt.setLayoutParams(new LinearLayout.LayoutParams(-1, -2));
txt.setText("Calendar");
txt.setPadding(0, 5, 0, 5);
txt.setTextColor(Color.BLACK);
txt.setGravity(Gravity.CENTER);
mreal.addView(txt);
View vo1 = new View(getContext());
vo1.setBackgroundColor(Color.parseColor("#ffffbb33"));
vo1.setLayoutParams(new LinearLayout.LayoutParams(-1, 2));
mreal.addView(vo1);
addButton(mreal);
View vo3 = new View(getContext());
vo3.setBackgroundColor(Color.parseColor("#ffffbb33"));
vo3.setLayoutParams(new LinearLayout.LayoutParams(-1, 2));
mreal.addView(vo3);
addCalender(mreal);
View vo2 = new View(getContext());
vo2.setBackgroundColor(Color.parseColor("#ffffbb33"));
vo2.setLayoutParams(new LinearLayout.LayoutParams(-1, 2));
mreal.addView(vo2);
this.setCancelable(true);
this.addContentView(mreal, mrealp);
}
ArrayList<Date> dater=null;
public void setArrayList(ArrayList<Date> dater)
{
this. dater=dater;
}
public String getMonth(int month) {
return new DateFormatSymbols().getMonths()[month];
}
private void addButton(LinearLayout mreal) {
int year = calendar.get(Calendar.YEAR);
int month = calendar.get(Calendar.MONTH);
LinearLayout ll = new LinearLayout(getContext());
ll.setLayoutParams(new LinearLayout.LayoutParams(-1, -2));
ll.setOrientation(LinearLayout.HORIZONTAL);
ImageView img = new ImageView(getContext());
img.setImageResource(android.R.drawable.btn_minus);
img.setLayoutParams(new LinearLayout.LayoutParams(-1, -2, 1.2f));
img.setOnClickListener(this);
img.setTag("0");
ll.addView(img);
txt = new TextView(getContext());
txt.setLayoutParams(new LinearLayout.LayoutParams(-1, -2, 1));
txt.setText(year + "");
txt.setTextColor(Color.BLACK);
txt.setGravity(Gravity.CENTER);
ll.addView(txt);
ImageView img1 = new ImageView(getContext());
img1.setImageResource(android.R.drawable.btn_plus);
img1.setLayoutParams(new LinearLayout.LayoutParams(-1, -2, 1.2f));
img1.setTag("1");
img1.setOnClickListener(this);
ll.addView(img1);
ImageView img3 = new ImageView(getContext());
img3.setImageResource(android.R.drawable.btn_minus);
img3.setLayoutParams(new LinearLayout.LayoutParams(-1, -2, 1.2f));
img3.setTag("2");
img3.setOnClickListener(this);
ll.addView(img3);
txt1 = new TextView(getContext());
txt1.setLayoutParams(new LinearLayout.LayoutParams(-1, -2, 1));
txt1.setText(getMonth(month));
txt1.setTag(month);
txt1.setTextColor(Color.BLACK);
txt1.setGravity(Gravity.CENTER);
ll.addView(txt1);
ImageView img4 = new ImageView(getContext());
img4.setImageResource(android.R.drawable.btn_plus);
img4.setLayoutParams(new LinearLayout.LayoutParams(-1, -2, 1.2f));
img4.setTag("3");
img4.setOnClickListener(this);
ll.addView(img4);
mreal.addView(ll);
}
private void addCalender(LinearLayout mreal) {
gd = new GridView(getContext());
gd.setLayoutParams(new LinearLayout.LayoutParams(-1, -2));
gd.setNumColumns(7);
gd.setCacheColorHint(android.R.color.transparent);
ArrayList<String> dat = getarrayList((calendar.get(Calendar.MONTH)),
calendar.get(Calendar.YEAR));
newmyadapter ad = setadap(dat);
gd.setAdapter(ad);
mreal.addView(gd);
}
private newmyadapter setadap(ArrayList<String> dat) {
newmyadapter ad = new newmyadapter( dat);
return ad;
}
private ArrayList<String> getarrayList(int month, int year) {
ArrayList<String> dat = new ArrayList<String>();
dat.add("Sun");
dat.add("Mon");
dat.add("Tue");
dat.add("Wed");
dat.add("Thu");
dat.add("Fri");
dat.add("Sat");
Calendar mycal =Calendar.getInstance();
mycal.set(year, month, 1);
System.out.println(year+"-"+month);
int days= mycal.getActualMaximum(Calendar.DAY_OF_MONTH);
try {
Date date1 = (new GregorianCalendar(year, month, 1)).getTime();
Format formatter = new SimpleDateFormat("EEEE");
String s = formatter.format(date1);
int h = 0;
String ne = s.toString().substring(0, 3);
System.out.println("ne" + ne);
if (ne.equalsIgnoreCase("sun")) {
h = 0;
} else if (ne.equalsIgnoreCase("mon")) {
h = 1;
} else if (ne.equalsIgnoreCase("tue")) {
h = 2;
} else if (ne.equalsIgnoreCase("wed")) {
h = 3;
} else if (ne.equalsIgnoreCase("thu")) {
h = 4;
} else if (ne.equalsIgnoreCase("fri")) {
h = 5;
} else if (ne.equalsIgnoreCase("sat")) {
h = 6;
}
System.out.println(h + "h");
for (int j = 0; j < h; j++) {
dat.add(".");
System.out.println(j + "h...");
}
} catch (Exception e) {
System.out.println(e.getMessage());
}
System.out.println(days);
for (int i = 1; i < days + 1; i++) {
dat.add(i + "");
}
return dat;
}
@Override
public void onClick(View v) {
int tag = Integer.parseInt(v.getTag().toString());
int next;
switch (tag) {
case 0:
next = Integer.parseInt(txt.getText().toString().trim()) - 1;
txt.setText(next + "");
gd.setAdapter(setadap(getarrayList(
Integer.parseInt(txt1.getTag().toString().trim()), next)));
break;
case 1:
next = Integer.parseInt(txt.getText().toString().trim()) + 1;
txt.setText(next + "");
gd.setAdapter(setadap(getarrayList(
Integer.parseInt(txt1.getTag().toString().trim()), next)));
break;
case 2:
next = (Integer.parseInt(txt1.getTag().toString().trim()) == 1) ? Integer
.parseInt(txt1.getTag().toString().trim()) : Integer
.parseInt(txt1.getTag().toString().trim()) - 1;
txt1.setText(getMonth(next));
txt1.setTag(next);
gd.setAdapter(setadap(getarrayList(next, next)));
break;
case 3:
next = (Integer.parseInt(txt1.getTag().toString().trim()) == 12) ? Integer
.parseInt(txt1.getTag().toString().trim()) : Integer
.parseInt(txt1.getTag().toString().trim()) + 1;
txt1.setText(getMonth(next));
txt1.setTag(next);
System.out.println("top" + next + "-"
+ Integer.parseInt(txt.getText().toString().trim()));
gd.setAdapter(setadap(getarrayList(next,
Integer.parseInt(txt.getText().toString().trim()))));
break;
default:
break;
}
}
public class newmyadapter extends BaseAdapter
{
protected ArrayList<String> data=null;
public newmyadapter(ArrayList<String> data)
{
this.data=data;
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return data.size();
}
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return null;
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
TextView txt=new TextView(getContext());
txt.setText(data.get(position));
txt.setGravity(Gravity.CENTER);
txt.setTextColor(Color.BLACK);
String datee=data.get(position)+"-"+Integer.parseInt(txt1.getTag().toString().trim())+"-"+txt.getText().toString().trim();
if(dater!=null)
{
if(dater.contains(datee))
{
txt.setBackgroundColor(Color.RED);
txt.setClickable(false);
}else
{
txt.setBackgroundColor(Color.GREEN);
txt.setOnClickListener(new android.view.View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
}
});
}
}
return txt;
}
}
}
Post data in android
try {
URL url = new URL(urls);
HttpURLConnection urlConnection = (HttpURLConnection) url
.openConnection();
urlConnection.setRequestMethod("GET");
urlConnection.setDoOutput(true);
urlConnection.connect();
File SDCardRoot = Environment.getExternalStorageDirectory();
File file = new File(SDCardRoot, dest);
FileOutputStream fileOutput = new FileOutputStream(file);
InputStream inputStream = urlConnection.getInputStream();
int totalSize = urlConnection.getContentLength();
Progress = "Starting image download...";
publishProgress("");
byte[] buffer = new byte[1024 * 1024];
int bufferLength = 0;
while ((bufferLength = inputStream.read(buffer)) > 0) {
fileOutput.write(buffer, 0, bufferLength);
int downloadedSize = bufferLength;
float per = ((float) downloadedSize / totalSize) * 100;
Progress = "Downloading image " + (int) per + "% complete";
publishProgress("");
}
fileOutput.close();
return setImage(dest);
} catch (final MalformedURLException e) {
}
String Proresss=null;
decodes image and scales bitmap it to reduce memory consumption
/** decodes image and scales it to reduce memory consumption **/
public static Bitmap getResizedBitmap(Bitmap bm, int newHeight, int newWidth) {
int width = bm.getWidth();
int height = bm.getHeight();
float scaleWidth = ((float) newWidth) / width;
float scaleHeight = ((float) newHeight) / height;
// CREATE A MATRIX FOR THE MANIPULATION
Matrix matrix = new Matrix();
// RESIZE THE BIT MAP
matrix.postScale(scaleWidth, scaleHeight);
// RECREATE THE NEW BITMAP
System.gc();
Bitmap resizedBitmap = Bitmap.createBitmap(bm, 0, 0, width, height,
matrix, false);
bm.recycle();
System.gc();
bm = null;
return resizedBitmap;
}
Custom Alert with extending Dialog in android
Create a your own class For alert in android Dynamically and save memory and learn java
----------------------------------------------
Code
----------------------------------------------
import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
/**
*
* @author Sudhi.S
*
*/
public class AlertTwoButton extends Dialog implements OnClickListener {
Context mcontext = null;
public AlertTwoButton(Context context) {
super(context, android.R.style.Theme_Panel);
mcontext = context;
initialization();
}
boolean multi = false;
boolean edit = false;
String msg10=null;
public AlertTwoButton(Context context, boolean edit,boolean multi,String msg) {
super(context, android.R.style.Theme_Panel);
mcontext = context;
this.edit=edit;
this.multi = multi;
msg10=msg;
initialization();
}
RelativeLayout mreal = null;
protected void initialization() {
mreal = new RelativeLayout(mcontext);
RelativeLayout.LayoutParams mrealp = new RelativeLayout.LayoutParams(
-1, -2);
mreal.setBackgroundResource(R.drawable.abs__dialog_full_holo_light);
this.addContentView(mreal, mrealp);
}
public void showDoubleButtonAlert(String mtitle, String mmsg, Integer mres,
String button1, String button2) {
if (mtitle != null && mmsg != null && mres != null) {
RelativeLayout.LayoutParams mrealp12 = new RelativeLayout.LayoutParams(
-1, -1);
mrealp12.setMargins(10, 10, 10, 10);
LinearLayout ll0 = new LinearLayout(mcontext);
ll0.setOrientation(LinearLayout.HORIZONTAL);
ll0.setLayoutParams(mrealp12);
ll0.setPadding(5, 5, 5, 5);
ImageView img = new ImageView(mcontext);
img.setLayoutParams(new LinearLayout.LayoutParams(-2, -1));
img.setImageResource(mres);
ll0.addView(img);
TextView txt = new TextView(mcontext);
txt.setLayoutParams(new LinearLayout.LayoutParams(-1, -1));
txt.setText(mtitle);
txt.setTextColor(Color.BLACK);
ll0.addView(txt);
LinearLayout.LayoutParams lop = new LinearLayout.LayoutParams(-1,
-2);
LinearLayout ll7 = new LinearLayout(mcontext);
lop.weight = 1;
ll7.setOrientation(LinearLayout.HORIZONTAL);
Button btn = new Button(mcontext);
btn.setLayoutParams(lop);
btn.setText(button1);
btn.setTextColor(Color.BLACK);
btn.setTag(0);
btn.setOnClickListener(this);
Button btn1 = new Button(mcontext);
btn1.setLayoutParams(lop);
btn1.setText(button2);
btn1.setTextColor(Color.BLACK);
btn1.setTag(1);
btn1.setOnClickListener(this);
ll7.addView(btn);
ll7.addView(btn1);
LinearLayout ll = new LinearLayout(mcontext);
ll.setOrientation(LinearLayout.VERTICAL);
RelativeLayout.LayoutParams mrealp1 = new RelativeLayout.LayoutParams(
-1, -2);
ll.setLayoutParams(mrealp1);
View v = new View(mcontext);
v.setLayoutParams(new RelativeLayout.LayoutParams(-1, 2));
v.setBackgroundColor(Color.parseColor("#A62A2A"));
View v1 = new View(mcontext);
v1.setLayoutParams(new RelativeLayout.LayoutParams(-1, 2));
v1.setBackgroundColor(Color.parseColor("#A62A2A"));
View v2 = new View(mcontext);
v2.setLayoutParams(new RelativeLayout.LayoutParams(-1, 2));
v2.setBackgroundColor(Color.parseColor("#A62A2A"));
View v3 = new View(mcontext);
v3.setLayoutParams(new RelativeLayout.LayoutParams(-1, 20));
View v4 = new View(mcontext);
v4.setLayoutParams(new RelativeLayout.LayoutParams(-1, 20));
ll.addView(v);
ll.addView(ll0);
ll.addView(v1);
ll.addView(v3);
RelativeLayout.LayoutParams mrealp2 = new RelativeLayout.LayoutParams(
-1, -2);
if (edit == false) {
TextView txt1 = new TextView(mcontext);
txt1.setLayoutParams(mrealp2);
txt1.setGravity(Gravity.CENTER);
txt1.setText(mmsg);
txt1.setTextColor(Color.BLACK);
ll.addView(txt1);
} else {
RelativeLayout.LayoutParams mre = new RelativeLayout.LayoutParams(
-1, -1);
txt0 = new EditText(mcontext);
txt0.setLayoutParams(mre);
txt0.setTag("msg");
txt0.setGravity(Gravity.TOP);
txt0.setHint(mmsg);
if(msg10!=null)
{
txt0.setText(msg10);
}
if(multi!=false)
{
txt0.setMinLines(5);
}else
{
txt0.setSingleLine(true);
}
txt0.setTextColor(Color.BLACK);
ll.addView(txt0);
}
ll.addView(v4);
ll.addView(v2);
ll.addView(ll7);
mreal.addView(ll);
}
this.show();
}
EditText txt0=null;
public void setButtonClickLisner(AlertTwoButtonListener mli) {
mlistener = mli;
}
AlertTwoButtonListener mlistener = null;
public void setEditButtonClickLisner(AlertEditTwoButtonListener mli) {
ml = mli;
}
public interface AlertTwoButtonListener {
public void onAlertFirstButtonClick();
public void onAlertSecondButtonClick();
}
AlertEditTwoButtonListener ml=null;
public interface AlertEditTwoButtonListener
{
public void onAlertEditFisrtButtonClick(String msg);
public void onAlertEditSecondButtonClick();
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
int which = ((Integer) v.getTag()).intValue();
if (mlistener != null)
{
switch (which) {
case 0:
mlistener.onAlertFirstButtonClick();
break;
case 1:
mlistener.onAlertSecondButtonClick();
break;
default:
break;
}
}else if (ml != null)
{
switch (which) {
case 0:
ml.onAlertEditFisrtButtonClick(txt0.getText().toString().trim()+"");
break;
case 1:
ml.onAlertEditSecondButtonClick();
break;
default:
break;
}
}
}
}
Custom Alert with extending Dialog in android
Create a your own class For alert in android Dynamically and save memory and learn java
----------------------------------------------
Code
----------------------------------------------
import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
/**
*
* @author Sudhi.S
*
*/
public class AlertTwoButton extends Dialog implements OnClickListener {
Context mcontext = null;
public AlertTwoButton(Context context) {
super(context, android.R.style.Theme_Panel);
mcontext = context;
initialization();
}
boolean multi = false;
boolean edit = false;
String msg10=null;
public AlertTwoButton(Context context, boolean edit,boolean multi,String msg) {
super(context, android.R.style.Theme_Panel);
mcontext = context;
this.edit=edit;
this.multi = multi;
msg10=msg;
initialization();
}
RelativeLayout mreal = null;
protected void initialization() {
mreal = new RelativeLayout(mcontext);
RelativeLayout.LayoutParams mrealp = new RelativeLayout.LayoutParams(
-1, -2);
mreal.setBackgroundResource(R.drawable.abs__dialog_full_holo_light);
this.addContentView(mreal, mrealp);
}
public void showDoubleButtonAlert(String mtitle, String mmsg, Integer mres,
String button1, String button2) {
if (mtitle != null && mmsg != null && mres != null) {
RelativeLayout.LayoutParams mrealp12 = new RelativeLayout.LayoutParams(
-1, -1);
mrealp12.setMargins(10, 10, 10, 10);
LinearLayout ll0 = new LinearLayout(mcontext);
ll0.setOrientation(LinearLayout.HORIZONTAL);
ll0.setLayoutParams(mrealp12);
ll0.setPadding(5, 5, 5, 5);
ImageView img = new ImageView(mcontext);
img.setLayoutParams(new LinearLayout.LayoutParams(-2, -1));
img.setImageResource(mres);
ll0.addView(img);
TextView txt = new TextView(mcontext);
txt.setLayoutParams(new LinearLayout.LayoutParams(-1, -1));
txt.setText(mtitle);
txt.setTextColor(Color.BLACK);
ll0.addView(txt);
LinearLayout.LayoutParams lop = new LinearLayout.LayoutParams(-1,
-2);
LinearLayout ll7 = new LinearLayout(mcontext);
lop.weight = 1;
ll7.setOrientation(LinearLayout.HORIZONTAL);
Button btn = new Button(mcontext);
btn.setLayoutParams(lop);
btn.setText(button1);
btn.setTextColor(Color.BLACK);
btn.setTag(0);
btn.setOnClickListener(this);
Button btn1 = new Button(mcontext);
btn1.setLayoutParams(lop);
btn1.setText(button2);
btn1.setTextColor(Color.BLACK);
btn1.setTag(1);
btn1.setOnClickListener(this);
ll7.addView(btn);
ll7.addView(btn1);
LinearLayout ll = new LinearLayout(mcontext);
ll.setOrientation(LinearLayout.VERTICAL);
RelativeLayout.LayoutParams mrealp1 = new RelativeLayout.LayoutParams(
-1, -2);
ll.setLayoutParams(mrealp1);
View v = new View(mcontext);
v.setLayoutParams(new RelativeLayout.LayoutParams(-1, 2));
v.setBackgroundColor(Color.parseColor("#A62A2A"));
View v1 = new View(mcontext);
v1.setLayoutParams(new RelativeLayout.LayoutParams(-1, 2));
v1.setBackgroundColor(Color.parseColor("#A62A2A"));
View v2 = new View(mcontext);
v2.setLayoutParams(new RelativeLayout.LayoutParams(-1, 2));
v2.setBackgroundColor(Color.parseColor("#A62A2A"));
View v3 = new View(mcontext);
v3.setLayoutParams(new RelativeLayout.LayoutParams(-1, 20));
View v4 = new View(mcontext);
v4.setLayoutParams(new RelativeLayout.LayoutParams(-1, 20));
ll.addView(v);
ll.addView(ll0);
ll.addView(v1);
ll.addView(v3);
RelativeLayout.LayoutParams mrealp2 = new RelativeLayout.LayoutParams(
-1, -2);
if (edit == false) {
TextView txt1 = new TextView(mcontext);
txt1.setLayoutParams(mrealp2);
txt1.setGravity(Gravity.CENTER);
txt1.setText(mmsg);
txt1.setTextColor(Color.BLACK);
ll.addView(txt1);
} else {
RelativeLayout.LayoutParams mre = new RelativeLayout.LayoutParams(
-1, -1);
txt0 = new EditText(mcontext);
txt0.setLayoutParams(mre);
txt0.setTag("msg");
txt0.setGravity(Gravity.TOP);
txt0.setHint(mmsg);
if(msg10!=null)
{
txt0.setText(msg10);
}
if(multi!=false)
{
txt0.setMinLines(5);
}else
{
txt0.setSingleLine(true);
}
txt0.setTextColor(Color.BLACK);
ll.addView(txt0);
}
ll.addView(v4);
ll.addView(v2);
ll.addView(ll7);
mreal.addView(ll);
}
this.show();
}
EditText txt0=null;
public void setButtonClickLisner(AlertTwoButtonListener mli) {
mlistener = mli;
}
AlertTwoButtonListener mlistener = null;
public void setEditButtonClickLisner(AlertEditTwoButtonListener mli) {
ml = mli;
}
public interface AlertTwoButtonListener {
public void onAlertFirstButtonClick();
public void onAlertSecondButtonClick();
}
AlertEditTwoButtonListener ml=null;
public interface AlertEditTwoButtonListener
{
public void onAlertEditFisrtButtonClick(String msg);
public void onAlertEditSecondButtonClick();
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
int which = ((Integer) v.getTag()).intValue();
if (mlistener != null)
{
switch (which) {
case 0:
mlistener.onAlertFirstButtonClick();
break;
case 1:
mlistener.onAlertSecondButtonClick();
break;
default:
break;
}
}else if (ml != null)
{
switch (which) {
case 0:
ml.onAlertEditFisrtButtonClick(txt0.getText().toString().trim()+"");
break;
case 1:
ml.onAlertEditSecondButtonClick();
break;
default:
break;
}
}
}
}
Subscribe to:
Posts (Atom)