1) Create a class progress dialog.java
============================
import android.app.Dialog;
import android.content.Context;
import android.text.Html;
import android.view.Window;
import android.widget.TextView;
public class ProcessDialog extends Dialog{
private TextView title;
public ProcessDialog(Context context,String strtitle,String strbody)
{
super(context);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.xcustomdialog);
setCancelable(true);
title = (TextView)findViewById(R.id.txtdialogtext);
title.setText(Html.fromHtml(strbody.toString()));
show();
}
}
2)xcustomdialog.xml
================
</LinearLayout>
3).JAVA CLASS
}
============================
import android.app.Dialog;
import android.content.Context;
import android.text.Html;
import android.view.Window;
import android.widget.TextView;
public class ProcessDialog extends Dialog{
private TextView title;
public ProcessDialog(Context context,String strtitle,String strbody)
{
super(context);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.xcustomdialog);
setCancelable(true);
title = (TextView)findViewById(R.id.txtdialogtext);
title.setText(Html.fromHtml(strbody.toString()));
show();
}
}
2)xcustomdialog.xml
================
<
LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:gravity="center"
android:layout_height="wrap_content">
<ProgressBar android:id="@+id/progressBar1"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</ProgressBar>
<TextView
android:id="@+id/txtdialogtext"
android:text="Loging ..."
android:layout_marginLeft="15dip"
android:layout_gravity="center"
android:textSize="18dip"
android:textColor="#FFF"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
3).JAVA CLASS
private class Sales_Inquiry extends AsyncTask<String, String, String>
{
private ProcessDialog mProcessDialog=null;
protected void onPreExecute() {
mProcessDialog = new ProcessDialog(SalesInquiry.this,Constant.PROGRESSBAR.SERVER,Constant.PROGRESSBAR.LOADING);
super.onPreExecute();
}
protected String doInBackground(String... params) {
String strURL = getResources().getString(R.string.
WEBSERVICE_URL);
ArrayList<NameValuePair> mNameValuePair =
new ArrayList<NameValuePair>();
mNameValuePair.add(
new BasicNameValuePair(Constant..BRAND, String.valueOf(intBrandID)));
mNameValuePair.add(
new BasicNameValuePair(Constant..PRODUCT, String.valueOf(intProductID)));
mNameValuePair.add(
new BasicNameValuePair(Constant.MODEL, String.valueOf(intModelID)));
mNameValuePair.add(
new BasicNameValuePair(Constant.COLOR, String.valueOf(intColorID)));
mNameValuePair.add(
new BasicNameValuePair(Constant..NAME_OF_OWNER, edtOwner_Name.getText().toString().trim()));
mNameValuePair.add(
new BasicNameValuePair(Constant.MOBILE_NO, edtMobile_No.getText().toString().trim()));
mNameValuePair.add(
new BasicNameValuePair(Constant.EMAIL_ID, edtEmail_ID.getText().toString().trim()));
System.out.println(
"Name Value ==="+mNameValuePair.toString());
return mCommanClass.PostConnection(strURL, mNameValuePair);
}
protected void onPostExecute(String result) {
mProcessDialog.dismiss();
if(result!=null){
System.out.println(
"Response====="+result);
try {
JSONObject mJSONOBJECT =
new JSONObject(result);
String strType = mJSONOBJECT.getString(Constant.JSON.
TYPE);
if(strType.equalsIgnoreCase(Constant.JSON.OK)){
strMessage = mJSONOBJECT.getString(Constant.JSON.MESSAGE);
SalesInquiryDialog();
//Toast.makeText(CLASSNMAE.this,mJSONOBJECT.getString(Constant.JSON.MESSAGE), Toast.LENGTH_SHORT).show();
// Intent mIntent=new Intent(CLASSNMAE.this,NEW.class);
// startActivity(mIntent);
// finish();
}
else{
strMessage = mJSONOBJECT.getString(Constant.JSON.MESSAGE);
SalesInquiryDialog();
//Toast.makeText(SalesInquiry.this,mJSONOBJECT.getString(Constant.JSON.MESSAGE), Toast.LENGTH_SHORT).show();
}
}
catch (Exception e){
e.printStackTrace();
}
}
else{
Toast.makeText(SalesInquiry.
this,Constant.SERVERCONNERROR, Toast.LENGTH_SHORT).show();
}
super.onPostExecute(result);
}
}
No comments:
Post a Comment