Wednesday 21 December 2011

json parsing


package com.ElightersCatalog;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;

import org.apache.http.NameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;

import android.util.Log;

public class webservice {
static String webservice_path = "http://site.elighters.com/catalogs/iphone/";



public static ArrayList<NameValuePair> BuildHeader(
String[] paramArrayOfString1, String[] paramArrayOfString2) {
ArrayList localArrayList = new ArrayList();
if (paramArrayOfString1 != null)
;
for (int i = 0;; i++) {
if (i >= paramArrayOfString1.length)
return localArrayList;
localArrayList.add(new BasicNameValuePair(paramArrayOfString1[i],
paramArrayOfString2[i]));
}
}

public static String Webservice_Call(String[] paramArrayOfString1,
String[] paramArrayOfString2, String paramString) {

String str1 = webservice_path + paramString;
try {
DefaultHttpClient localDefaultHttpClient = new DefaultHttpClient();
HttpPost localHttpPost = new HttpPost(str1);
localHttpPost.setEntity(new UrlEncodedFormEntity(BuildHeader(
paramArrayOfString1, paramArrayOfString2)));
InputStream localInputStream = localDefaultHttpClient
.execute(localHttpPost).getEntity().getContent();

BufferedReader localBufferedReader = new BufferedReader(
new InputStreamReader(localInputStream, "iso-8859-1"), 8);
StringBuilder localStringBuilder = new StringBuilder();
while (true) {
String str2 = null;

try {
while ((str2 = localBufferedReader.readLine()) != null) {
localStringBuilder.append(str2 + "\n");
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
localInputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
String text = localStringBuilder.toString();
return text;
}

} catch (Exception localException2) {
while (true)
Log.e("log_tag",
"Error converting result " + localException2.toString());
}
}

}

calling file=>

package com.ElightersCatalog;

import java.util.ArrayList;
import java.util.HashMap;

import org.json.JSONArray;
import org.json.JSONException;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.Toast;

public class HorizontalListViewDemo extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.listviewdemo);

HorizontalListView listview = (HorizontalListView) findViewById(R.id.listview);
listview.setAdapter(mAdapter);
String function = "fetch_products.php";
String[] a = new String[] { "android" };
String[] b = new String[] { "yes" };
try {
JSONArray localJSONArray = new JSONArray(
webservice.Webservice_Call(a, b, function));
Log.e("response", "" + localJSONArray.toString());
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public class productdata
 {
   String[] FImage_url;
   String[] Product_Name;
   String[] Product_desc;
   String[] Product_price;
   String[] Product_sale_price;
   String[] Product_url;
   String[] YahooID;
   int page_num;
   int total_data = 0;

   public productdata()
   {
   }
 }

private static String[] dataObjects = new String[] { "1", "2", "3", "4",
"5", "6", "7", "8", "9", "10" };

private BaseAdapter mAdapter = new BaseAdapter() {

@Override
public int getCount() {
return dataObjects.length;
}

@Override
public Object getItem(int position) {
return null;
}

@Override
public long getItemId(int position) {
return 0;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
final int pos = position;
View retval = LayoutInflater.from(parent.getContext()).inflate(
R.layout.viewitem, null);
// TextView title = (TextView) retval.findViewById(R.id.title);
// title.setText(dataObjects[position]);
final Button bt = (Button) retval.findViewById(R.id.btview);
bt.setText(dataObjects[position]);
bt.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
// String btname;

Log.v("log_tag", "here the position of it");
Toast.makeText(HorizontalListViewDemo.this,
"button is clicked", Toast.LENGTH_SHORT).show();
Log.v("log_tag", "bt clicked");
}
});

return retval;

}

};

}

Sunday 11 December 2011

spinner mylijsl


package com.LIJSL.MyLIJSL;

import java.util.ArrayList;
import java.util.HashMap;

import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.Display;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.view.Window;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;

import com.LIJSL.Internet_Check;
import com.LIJSL.Ksoap;
import com.LIJSL.Main;
import com.LIJSL.R;
import com.LIJSL.ScreenConfg;

public class LiMyLijsl extends Activity {

Spinner spinner_season, spinner_divison;
int width;
ListView mystandings, myschedule;
SimpleAdapter adapter_standing, adapter_schedule;
ArrayList<HashMap<String, String>> list_standing = new ArrayList<HashMap<String, String>>();
final ArrayList<HashMap<String, String>> list_schedule = new ArrayList<HashMap<String, String>>();

ArrayList<HashMap<String, String>> list_data = new ArrayList<HashMap<String, String>>();

ProgressDialog dialog;
String[] Value, ISCURRENT, Text;
int total_data, total_data_div;
ArrayAdapter<String> adapter, adapter_div;
int season_position;
int division_position;
String[] Value_div, Text_div;

private boolean display = false;
private boolean dis_standing = false;
private boolean dis_schedule = false;
private boolean tab_chenge = false;

private Button mySchedule;
private Button myStanding;

private ListView schedule_list;

// Variable For Division Substring data

private String mGender;
private String mYear;
private String division_value_sub_string;
private String division_value;

// Standing Data

String[] Rank, TeamID, TeamName, Wins, Losses, Ties, GoalsFor,
GoalsAgianest, Points;
int all_standing_list;

// schedule data

String[] HomeTeamID, HomeTeamName, HomeScore, AwayTeamId, AwayTeamName,
AwayScore;
int all_schedule_list;

ImageView heading_image;

// Back Button

private Button back;
private TextView top_text;

// screen size check
private boolean checkofmedium;
private boolean checkoflarge;
private boolean checkofNormal;

// Check Screen Orientation

int screenOrientation;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

checkofmedium = ScreenConfg.checkScreenSize(getWindowManager());
checkoflarge = ScreenConfg.checkScreenSize_10(getWindowManager());
checkofNormal = ScreenConfg.checkScreenSize_Normal(getWindowManager());

if (checkofNormal) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}

requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.limylijsl);

screenOrientation = getScreenOrientation();

top_text = (TextView) findViewById(R.id.top_text);
top_text.setText("MY STANDINGS");

back = (Button) findViewById(R.id.back);

back.setOnClickListener(new View.OnClickListener() {

public void onClick(View v) {
// TODO Auto-generated method stub
Intent i = new Intent(LiMyLijsl.this, Main.class);
startActivity(i);
finish();
}
});

// dynamically adjusting width of spinner

spinner_season = (Spinner) findViewById(R.id.spinner_season);
WindowManager w = getWindowManager();
Display d = w.getDefaultDisplay();
width = d.getWidth();
LayoutParams l = spinner_season.getLayoutParams();
l.width = width / 2;
spinner_season.setLayoutParams(l);

spinner_divison = (Spinner) findViewById(R.id.spinner_divison);
LayoutParams m = spinner_divison.getLayoutParams();
m.width = width / 2;
spinner_divison.setLayoutParams(m);
dialog = ProgressDialog.show(this, "", "Loading Data ...Please Wait",
true);

mySchedule = (Button) findViewById(R.id.btn_myschedule);
myStanding = (Button) findViewById(R.id.btn_mystandings);

mystandings = (ListView) findViewById(R.id.list_standing);
myschedule = (ListView) findViewById(R.id.list_schedule);

heading_image = (ImageView) findViewById(R.id.heading_list);

adapter_standing = new SimpleAdapter(this, list_standing,
R.layout.standing,
new String[] { "Rank", "TeamName", "Wins", "Losses", "Ties",
"GoalsFor", "GoalsAgianest", "Points" }, new int[] {
R.id.rank, R.id.name, R.id.wins, R.id.loss, R.id.ties,
R.id.goalfor, R.id.goalagainst, R.id.points });

// First call checkupdate data for getting season data

if (Internet_Check.checkInternetConnection(getApplicationContext())) {
checkUpdate ListUpdate = new checkUpdate();
ListUpdate.start();
} else {
Alert_dialog();
dialog.dismiss();
}
mySchedule.setOnClickListener(new View.OnClickListener() {

public void onClick(View v) {
// TODO Auto-generated method stub

top_text.setText("MY SCHEDULE");

list_standing.clear();
mystandings.setVisibility(View.INVISIBLE);
myschedule.setVisibility(View.VISIBLE);

if (screenOrientation == 1) {
if (checkofmedium) {
mySchedule
.setBackgroundResource(R.drawable.scheduleact_240);
myStanding
.setBackgroundResource(R.drawable.standing_240);
heading_image.setImageResource(R.drawable.myschedule);

} else if (checkoflarge) {
mySchedule
.setBackgroundResource(R.drawable.myscheduleact_160_port);
myStanding
.setBackgroundResource(R.drawable.mystanding_160_port);
heading_image
.setImageResource(R.drawable.linemyschedule_160_port);
} else if (checkofNormal) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
mySchedule
.setBackgroundResource(R.drawable.scheduleact);
myStanding.setBackgroundResource(R.drawable.standing);
heading_image.setImageResource(R.drawable.myschedule);
}
} else if (screenOrientation == 2) {
if (checkofmedium) {
mySchedule
.setBackgroundResource(R.drawable.scheduleact_240_land);
myStanding
.setBackgroundResource(R.drawable.standing_240_land);
heading_image
.setImageResource(R.drawable.line_myschedule_240_land);

} else if (checkoflarge) {
mySchedule
.setBackgroundResource(R.drawable.scheduleact_160);
myStanding
.setBackgroundResource(R.drawable.standing_160);
heading_image
.setImageResource(R.drawable.myschedule_160);
} else if (checkofNormal) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
mySchedule
.setBackgroundResource(R.drawable.scheduleact);
myStanding.setBackgroundResource(R.drawable.standing);
heading_image.setImageResource(R.drawable.myschedule);
}
}

populateList_Schedule();

adapter_schedule = new SimpleAdapter(LiMyLijsl.this,
list_schedule, R.layout.schedule, new String[] {
"HomeTeamName", "HomeScore", "Vs", "AwayScore",
"AwayTeamName" }, new int[] {
R.id.home_team_name, R.id.home_score, R.id.vs,
R.id.away_score, R.id.away_team_name });
myschedule.setAdapter(adapter_schedule);
tab_chenge = true;
}
});

myStanding.setOnClickListener(new View.OnClickListener() {

public void onClick(View v) {
// TODO Auto-generated method stub

top_text.setText("MY STANDINGS");
list_standing.clear();
mystandings.setVisibility(View.VISIBLE);
myschedule.setVisibility(ListView.INVISIBLE);

if (screenOrientation == 1) {

if (checkofmedium) {
mySchedule
.setBackgroundResource(R.drawable.schedule_240);
myStanding
.setBackgroundResource(R.drawable.standingact_240);
heading_image.setImageResource(R.drawable.linemystand);
} else if (checkoflarge) {
mySchedule
.setBackgroundResource(R.drawable.myschedule_160_port);
myStanding
.setBackgroundResource(R.drawable.mystandingact_160_port);
heading_image
.setImageResource(R.drawable.linemystand_160_port);
} else if (checkofNormal) {
mySchedule.setBackgroundResource(R.drawable.schedule);
myStanding
.setBackgroundResource(R.drawable.standingact);
heading_image.setImageResource(R.drawable.linemystand);
}
} else if (screenOrientation == 2) {
if (checkofmedium) {
mySchedule
.setBackgroundResource(R.drawable.schedule_240_land);
myStanding
.setBackgroundResource(R.drawable.standingact_240_land);
heading_image
.setImageResource(R.drawable.line_mystand_240_land);
} else if (checkoflarge) {
mySchedule
.setBackgroundResource(R.drawable.schedule_160);
myStanding
.setBackgroundResource(R.drawable.standingact_160);
heading_image
.setImageResource(R.drawable.linemystand_160);
} else if (checkofNormal) {
mySchedule.setBackgroundResource(R.drawable.schedule);
myStanding
.setBackgroundResource(R.drawable.standingact);
heading_image.setImageResource(R.drawable.linemystand);
}
}

populateList_standing();

adapter_standing = new SimpleAdapter(LiMyLijsl.this,
list_standing, R.layout.standing, new String[] {
"Rank", "TeamName", "Wins", "Losses", "Ties",
"GoalsFor", "GoalsAgianest", "Points" },
new int[] { R.id.rank, R.id.name, R.id.wins, R.id.loss,
R.id.ties, R.id.goalfor, R.id.goalagainst,
R.id.points });
mystandings.setAdapter(adapter_standing);
tab_chenge = false;
}
});

}

@Override
protected void onStop() {
super.onStop();
if (dialog != null) {
dialog.dismiss();
}
}

public int getScreenOrientation() {
Display getOrient = getWindowManager().getDefaultDisplay();
int orientation = Configuration.ORIENTATION_UNDEFINED;
if (getOrient.getWidth() == getOrient.getHeight()) {
orientation = Configuration.ORIENTATION_SQUARE;
} else {
if (getOrient.getWidth() < getOrient.getHeight()) {
orientation = Configuration.ORIENTATION_PORTRAIT;
} else {
orientation = Configuration.ORIENTATION_LANDSCAPE;
}
}
return orientation;
}

private void Alert_dialog() {
// Create the dialog box
AlertDialog.Builder alertbox = new AlertDialog.Builder(LiMyLijsl.this);
alertbox.setTitle("Connection Error");
// Set the message to display
alertbox.setMessage("Please Check is your internet connection");
// Set a positive/yes button and create a listener
alertbox.setPositiveButton("OK", new DialogInterface.OnClickListener() {
// Click listener
public void onClick(DialogInterface arg0, int arg1) {
Intent i = new Intent(LiMyLijsl.this, Main.class);
startActivity(i);
finish();
}
});
// display box
alertbox.show();

}

// All The Season data

/* thread to fetch the data using webservice */

class checkUpdate extends Thread {

public void run() {
PropertyInfo total_property[] = null;
SoapObject Soapresponse = Ksoap.CallService("GetSeason", 0,
total_property);
try {
if (Soapresponse != null) {
SoapObject Soapresult = (SoapObject) Soapresponse
.getProperty(0);

if (Soapresult != null) {
SoapObject Dataset = (SoapObject) Soapresult
.getProperty(1);
if (Dataset != null) {
SoapObject Table = (SoapObject) Dataset
.getProperty(0);
if (Table != null) {
Value = new String[Table.getPropertyCount()];
Text = new String[Table.getPropertyCount()];
ISCURRENT = new String[Table.getPropertyCount()];

// IsCurrent = new
// String[Table.getPropertyCount()];
// String temp="";
total_data = Table.getPropertyCount();

for (int i = 0; i < total_data; i++) {
SoapObject row = (SoapObject) Table
.getProperty(i);
try {
Value[i] = row.getProperty("Value")
.toString();
Text[i] = row.getProperty("Text")
.toString();
ISCURRENT[i] = row.getProperty(
"ISCURRENT").toString();
} catch (NullPointerException e) {
}
}
// TextView t =
// (TextView)this.findViewById(R.id.resultbox);
// t.setText(temp);
}
}
}
}
} catch (NullPointerException f) {

} catch (ClassCastException d) {

}
handler.sendEmptyMessage(0);
}
};

// Now call season data handler
final Handler handler = new Handler() {
public void handleMessage(Message msg) {

if (Text == null) {

} else {

adapter = new ArrayAdapter<String>(getApplicationContext(),
android.R.layout.simple_spinner_item, Text);
spinner_season.setAdapter(adapter);
spinner_season
.setOnItemSelectedListener(new MyOnItemSelectedListener_season());

// setting appropriate elsement as selected in spinner

int z = 0;
for (int h = 0; h < total_data; h++) {
if (ISCURRENT[h].equalsIgnoreCase("1"))
z = h;

}
season_position = z;
spinner_season.setSelection(z);

checkUpdate_div ListUpdateDiv = new checkUpdate_div();
ListUpdateDiv.start();

}
}
};

// Then call division data for display

// All Division Data

class checkUpdate_div extends Thread {
public void run() {

PropertyInfo p[] = new PropertyInfo[1];
p[0] = new PropertyInfo();

p[0].type = PropertyInfo.STRING_CLASS;
p[0].setName("SeasonId");
p[0].setValue(Value[season_position]);

// Log.e("value++", p[0].toString());
// String g[] = new String[1];
// String h[] = new String[1];
// g[0] = "SeasonId";
// h[0] = "5";
SoapObject Soapresponse = Ksoap.CallService("GetDivisions", 1, p);

try {
if (Soapresponse != null) {
SoapObject Soapresult = (SoapObject) Soapresponse
.getProperty(0);

if (Soapresult != null) {
SoapObject Dataset = (SoapObject) Soapresult
.getProperty(1);
if (Dataset != null) {
SoapObject Table = (SoapObject) Dataset
.getProperty(0);
if (Table != null) {
Value_div = new String[Table.getPropertyCount()];
Text_div = new String[Table.getPropertyCount()];

total_data_div = Table.getPropertyCount();

for (int i = 0; i < total_data_div; i++) {
SoapObject row = (SoapObject) Table
.getProperty(i);
try {
Value_div[i] = row.getProperty("Value")
.toString();
Text_div[i] = row.getProperty("Text")
.toString();

} catch (NullPointerException e) {

}

}
// TextView t =
// (TextView)this.findViewById(R.id.resultbox);
// t.setText(temp);
}
}
}
}
} catch (NullPointerException f) {

} catch (ClassCastException d) {

}
handler_div.sendEmptyMessage(0);
}
};

// division data handler

final Handler handler_div = new Handler() {
public void handleMessage(Message msg) {

try {
adapter_div = new ArrayAdapter<String>(getApplicationContext(),
android.R.layout.simple_spinner_item, Text_div);
adapter_div
.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner_divison.setAdapter(adapter_div);
spinner_divison
.setOnItemSelectedListener(new MyOnItemSelectedListener_div());
display = true;
if (dis_standing == false) {
list_standing_data ListStandingData = new list_standing_data();
ListStandingData.start();
}
} catch (NullPointerException f) {

}
}
};

class list_standing_data extends Thread {

public void run() {
division_value_sub_string = Value_div[division_position];

mGender = division_value_sub_string.substring(0, 1);

mYear = division_value_sub_string.substring(2, 6);

division_value = division_value_sub_string.substring(7);

// Log.v("log_tag", "Division Value    " +
// division_value_sub_string);
// Log.v("log_tag", "All   Season   " + Value[season_position]);
// Log.v("log_tag", "All   Gender   " + mGender);
// Log.v("log_tag", "All Year  " + mYear);
// Log.v("log_tag", "All division value  " + division_value);
// Log.v("log_tag", "All division value 22 "
// + spinner_season.getSelectedItem().toString());
// Log.v("log_tag", "All division value 33 "
// + spinner_divison.getSelectedItem().toString());

// Set Season Value

PropertyInfo p[] = new PropertyInfo[4];
p[0] = new PropertyInfo();
p[0].type = PropertyInfo.STRING_CLASS;
p[0].setName("SeasonId");
p[0].setValue(Value[season_position]);

// Set Gender Value

p[1] = new PropertyInfo();
p[1].type = PropertyInfo.STRING_CLASS;
p[1].setName("Gender");
p[1].setValue(mGender);

// Set Year Data

p[2] = new PropertyInfo();
p[2].type = PropertyInfo.STRING_CLASS;
p[2].setName("TeamYear");
p[2].setValue(mYear);

// Set Division Data

p[3] = new PropertyInfo();
p[3].type = PropertyInfo.STRING_CLASS;
p[3].setName("DivisionId");
p[3].setValue(division_value);

SoapObject Soapresponse = Ksoap
.CallService("GetstandingData", 4, p);

try {
if (Soapresponse != null) {
SoapObject Soapresult = (SoapObject) Soapresponse
.getProperty(0);

if (Soapresult != null) {
SoapObject Dataset = (SoapObject) Soapresult
.getProperty(1);
if (Dataset != null) {
SoapObject Table = (SoapObject) Dataset
.getProperty(0);
if (Table != null) {
Rank = new String[Table.getPropertyCount()];
TeamID = new String[Table.getPropertyCount()];
TeamName = new String[Table.getPropertyCount()];
Wins = new String[Table.getPropertyCount()];
Losses = new String[Table.getPropertyCount()];
Ties = new String[Table.getPropertyCount()];
GoalsFor = new String[Table.getPropertyCount()];
GoalsAgianest = new String[Table
.getPropertyCount()];
Points = new String[Table.getPropertyCount()];

all_standing_list = Table.getPropertyCount();

for (int i = 0; i < all_standing_list; i++) {
SoapObject row = (SoapObject) Table
.getProperty(i);
try {
Rank[i] = row.getProperty("RANK")
.toString();
TeamID[i] = row.getProperty("TEAMID")
.toString();
TeamName[i] = row.getProperty(
"TEAMNAME").toString();
Wins[i] = row.getProperty("WINS")
.toString();
Losses[i] = row.getProperty("LOSSES")
.toString();
Ties[i] = row.getProperty("TIES")
.toString();
GoalsFor[i] = row.getProperty(
"GoalsFor").toString();
GoalsAgianest[i] = row.getProperty(
"GoalsAgainst").toString();
Points[i] = row.getProperty("Points")
.toString();

} catch (NullPointerException e) {

}

}
}
}
}
}
} catch (NullPointerException f) {

} catch (ClassCastException d) {

}
listed_season_display.sendEmptyMessage(0);
}

};

final Handler listed_season_display = new Handler() {
public void handleMessage(Message msg) {

try {
list_standing.clear();
populateList_standing();
mystandings.setAdapter(adapter_standing);
dis_standing = true;
dialog.dismiss();
} catch (NullPointerException f) {
Toast.makeText(getApplicationContext(),
"web service is down ..try after some time", 2000)
.show();
}
if (dis_schedule == false) {

list_schedule_data ListScheduleData = new list_schedule_data();
ListScheduleData.start();

} else {

list_schedule_of_all_data ListScheduleofAllData = new list_schedule_of_all_data();
ListScheduleofAllData.start();

}
}
};

// spinner of season data

class MyOnItemSelectedListener_season implements OnItemSelectedListener {

public void onItemSelected(AdapterView<?> parent, View view, int pos,
long id) {
if (display == false) {
season_position = pos;
} else {
season_position = pos;
// Thread Error Solve call this Function

season_data_spinner SeasonDataSpinner = new season_data_spinner();
SeasonDataSpinner.start();

}
}

public void onNothingSelected(AdapterView<?> parent) {
// Do nothing.
}
}

// spinner of division data

class MyOnItemSelectedListener_div implements OnItemSelectedListener {

public void onItemSelected(AdapterView<?> parent, View view, int pos,
long id) {

if (dis_standing == false) {
division_position = pos;

} else {
division_position = pos;

// Thread Error Solve call this Function

dialog = ProgressDialog.show(LiMyLijsl.this, "",
"Loading Data ...Please Wait", true);

all_data_for_season_division AlldataForSpinnerDivison = new all_data_for_season_division();
AlldataForSpinnerDivison.start();
}

}

public void onNothingSelected(AdapterView<?> parent) {
// Do nothing.
}
}

// Listview DAta for standing data

private void populateList_standing() {

for (int i = 0; i < all_standing_list; i++) {
HashMap<String, String> temp = new HashMap<String, String>();

temp.put("Rank", Rank[i]);
temp.put("TeamName", TeamName[i]);
temp.put("Wins", Wins[i]);
temp.put("Losses", Losses[i]);
temp.put("Ties", Ties[i]);
temp.put("GoalsFor", GoalsFor[i]);
temp.put("GoalsAgianest", GoalsAgianest[i]);
temp.put("Points", Points[i]);
list_standing.add(temp);
}
}

// Listveiw Data For Schedule data

private void populateList_Schedule() {

for (int i = 0; i < all_schedule_list; i++) {
HashMap<String, String> temp = new HashMap<String, String>();
temp.put("HomeTeamName", HomeTeamName[i]);
temp.put("HomeScore", HomeScore[i]);
temp.put("AwayTeamName", AwayTeamName[i]);
temp.put("AwayScore", AwayScore[i]);
temp.put("Vs", "Vs.");
list_schedule.add(temp);
}
}

// Function for thread error

class season_data_spinner extends Thread {
public void run() {

// season_data_spinner_dialog.start();

PropertyInfo p[] = new PropertyInfo[1];
p[0] = new PropertyInfo();

p[0].type = PropertyInfo.STRING_CLASS;
p[0].setName("SeasonId");

p[0].setValue(Value[season_position]);
SoapObject Soapresponse = Ksoap.CallService("GetDivisions", 1, p);

try {
if (Soapresponse != null) {
SoapObject Soapresult = (SoapObject) Soapresponse
.getProperty(0);

if (Soapresult != null) {
SoapObject Dataset = (SoapObject) Soapresult
.getProperty(1);
if (Dataset != null) {
SoapObject Table = (SoapObject) Dataset
.getProperty(0);
if (Table != null) {
Value_div = new String[Table.getPropertyCount()];
Text_div = new String[Table.getPropertyCount()];

total_data_div = Table.getPropertyCount();

for (int i = 0; i < total_data_div; i++) {
SoapObject row = (SoapObject) Table
.getProperty(i);
try {
Value_div[i] = row.getProperty("Value")
.toString();
Text_div[i] = row.getProperty("Text")
.toString();

} catch (NullPointerException e) {

}

}
}
}
}
}
} catch (NullPointerException f) {

} catch (ClassCastException d) {

}

handler_div.sendEmptyMessage(0);

}
};

class season_data_spinner_dialog extends Thread {
public void run() {

PropertyInfo p[] = new PropertyInfo[1];
p[0] = new PropertyInfo();

p[0].type = PropertyInfo.STRING_CLASS;
p[0].setName("SeasonId");

p[0].setValue(Value[season_position]);
SoapObject Soapresponse = Ksoap.CallService("GetDivisions", 1, p);

try {
if (Soapresponse != null) {
SoapObject Soapresult = (SoapObject) Soapresponse
.getProperty(0);

if (Soapresult != null) {
SoapObject Dataset = (SoapObject) Soapresult
.getProperty(1);
if (Dataset != null) {
SoapObject Table = (SoapObject) Dataset
.getProperty(0);
if (Table != null) {
Value_div = new String[Table.getPropertyCount()];
Text_div = new String[Table.getPropertyCount()];

total_data_div = Table.getPropertyCount();

for (int i = 0; i < total_data_div; i++) {
SoapObject row = (SoapObject) Table
.getProperty(i);
try {
Value_div[i] = row.getProperty("Value")
.toString();
Text_div[i] = row.getProperty("Text")
.toString();

} catch (NullPointerException e) {

}

}
}
}
}
}
} catch (NullPointerException f) {

} catch (ClassCastException d) {

}

handler_div.sendEmptyMessage(0);

}
};

// All Listview Data

// Function for thread error

class all_data_for_season_division extends Thread {
public void run() {

division_value_sub_string = Value_div[division_position];

mGender = division_value_sub_string.substring(0, 1);

mYear = division_value_sub_string.substring(2, 6);

division_value = division_value_sub_string.substring(7);

// Set Season Value

PropertyInfo p[] = new PropertyInfo[4];
p[0] = new PropertyInfo();
p[0].type = PropertyInfo.STRING_CLASS;
p[0].setName("SeasonId");
p[0].setValue(Value[season_position]);

// Set Gender Value

p[1] = new PropertyInfo();
p[1].type = PropertyInfo.STRING_CLASS;
p[1].setName("Gender");
p[1].setValue(mGender);

// Set Year Data

p[2] = new PropertyInfo();
p[2].type = PropertyInfo.STRING_CLASS;
p[2].setName("TeamYear");
p[2].setValue(mYear);

// Set Division Data

p[3] = new PropertyInfo();
p[3].type = PropertyInfo.STRING_CLASS;
p[3].setName("DivisionId");
p[3].setValue(division_value);

SoapObject Soapresponse = Ksoap
.CallService("GetstandingData", 4, p);

try {
if (Soapresponse != null) {
SoapObject Soapresult = (SoapObject) Soapresponse
.getProperty(0);

if (Soapresult != null) {
SoapObject Dataset = (SoapObject) Soapresult
.getProperty(1);
if (Dataset != null) {
SoapObject Table = (SoapObject) Dataset
.getProperty(0);
if (Table != null) {
Rank = new String[Table.getPropertyCount()];
TeamID = new String[Table.getPropertyCount()];
TeamName = new String[Table.getPropertyCount()];
Wins = new String[Table.getPropertyCount()];
Losses = new String[Table.getPropertyCount()];
Ties = new String[Table.getPropertyCount()];
GoalsFor = new String[Table.getPropertyCount()];
GoalsAgianest = new String[Table
.getPropertyCount()];
Points = new String[Table.getPropertyCount()];

all_standing_list = Table.getPropertyCount();

for (int i = 0; i < all_standing_list; i++) {
SoapObject row = (SoapObject) Table
.getProperty(i);
try {
Rank[i] = row.getProperty("RANK")
.toString();
TeamID[i] = row.getProperty("TEAMID")
.toString();
TeamName[i] = row.getProperty(
"TEAMNAME").toString();
Wins[i] = row.getProperty("WINS")
.toString();
Losses[i] = row.getProperty("LOSSES")
.toString();
Ties[i] = row.getProperty("TIES")
.toString();
GoalsFor[i] = row.getProperty(
"GoalsFor").toString();
GoalsAgianest[i] = row.getProperty(
"GoalsAgainst").toString();
Points[i] = row.getProperty("Points")
.toString();

} catch (NullPointerException e) {

}

}
}
}
}
}
} catch (NullPointerException f) {

} catch (ClassCastException d) {

}
listed_season_display.sendEmptyMessage(0);
}
};

// Now starting the schedule data
class list_schedule_data extends Thread {
public void run() {

division_value_sub_string = Value_div[division_position];

mGender = division_value_sub_string.substring(0, 1);

mYear = division_value_sub_string.substring(2, 6);

division_value = division_value_sub_string.substring(7);

// Set Season Value

PropertyInfo p[] = new PropertyInfo[4];
p[0] = new PropertyInfo();
p[0].type = PropertyInfo.STRING_CLASS;
p[0].setName("SeasonId");
p[0].setValue(Value[season_position]);

// Set Gender Value

p[1] = new PropertyInfo();
p[1].type = PropertyInfo.STRING_CLASS;
p[1].setName("Gender");
p[1].setValue(mGender);

// Set Year Data

p[2] = new PropertyInfo();
p[2].type = PropertyInfo.STRING_CLASS;
p[2].setName("TeamYear");
p[2].setValue(mYear);

// Set Division Data

p[3] = new PropertyInfo();
p[3].type = PropertyInfo.STRING_CLASS;
p[3].setName("DivisionId");
p[3].setValue(division_value);

SoapObject Soapresponse = Ksoap
.CallService("GetScheduleData", 4, p);

try {
if (Soapresponse != null) {
SoapObject Soapresult = (SoapObject) Soapresponse
.getProperty(0);

if (Soapresult != null) {
SoapObject Dataset = (SoapObject) Soapresult
.getProperty(1);
if (Dataset != null) {
SoapObject Table = (SoapObject) Dataset
.getProperty(0);
if (Table != null) {
HomeTeamID = new String[Table
.getPropertyCount()];
HomeTeamName = new String[Table
.getPropertyCount()];
HomeScore = new String[Table.getPropertyCount()];
AwayTeamId = new String[Table
.getPropertyCount()];
AwayTeamName = new String[Table
.getPropertyCount()];
AwayScore = new String[Table.getPropertyCount()];

all_schedule_list = Table.getPropertyCount();

for (int i = 0; i < all_schedule_list; i++) {
SoapObject row = (SoapObject) Table
.getProperty(i);
try {
HomeTeamID[i] = row.getProperty(
"HomeTeamId").toString();
HomeTeamName[i] = row.getProperty(
"HomeTeamName").toString();
HomeScore[i] = row
.getProperty("HomeScore")
.toString().replace("-1", "0");
AwayTeamId[i] = row.getProperty(
"AwayTeamId").toString();
AwayTeamName[i] = row.getProperty(
"AwayTeamName").toString();
AwayScore[i] = row
.getProperty("AwayScore")
.toString().replace("-1", "0");

} catch (NullPointerException e) {

}

}
}
}
}
}
} catch (NullPointerException f) {

} catch (ClassCastException d) {

}
listed_schedule_display.sendEmptyMessage(0);
}

};

// Function for solving Error On schedule

class list_schedule_of_all_data extends Thread {
public void run() {

division_value_sub_string = Value_div[division_position];

mGender = division_value_sub_string.substring(0, 1);

mYear = division_value_sub_string.substring(2, 6);

division_value = division_value_sub_string.substring(7);

// Set Season Value

PropertyInfo p[] = new PropertyInfo[4];
p[0] = new PropertyInfo();
p[0].type = PropertyInfo.STRING_CLASS;
p[0].setName("SeasonId");
p[0].setValue(Value[season_position]);

// Set Gender Value

p[1] = new PropertyInfo();
p[1].type = PropertyInfo.STRING_CLASS;
p[1].setName("Gender");
p[1].setValue(mGender);

// Set Year Data

p[2] = new PropertyInfo();
p[2].type = PropertyInfo.STRING_CLASS;
p[2].setName("TeamYear");
p[2].setValue(mYear);

// Set Division Data

p[3] = new PropertyInfo();
p[3].type = PropertyInfo.STRING_CLASS;
p[3].setName("DivisionId");
p[3].setValue(division_value);

SoapObject Soapresponse = Ksoap
.CallService("GetScheduleData", 4, p);

try {
if (Soapresponse != null) {
SoapObject Soapresult = (SoapObject) Soapresponse
.getProperty(0);

if (Soapresult != null) {
SoapObject Dataset = (SoapObject) Soapresult
.getProperty(1);
if (Dataset != null) {
SoapObject Table = (SoapObject) Dataset
.getProperty(0);
if (Table != null) {
HomeTeamID = new String[Table
.getPropertyCount()];
HomeTeamName = new String[Table
.getPropertyCount()];
HomeScore = new String[Table.getPropertyCount()];
AwayTeamId = new String[Table
.getPropertyCount()];
AwayTeamName = new String[Table
.getPropertyCount()];
AwayScore = new String[Table.getPropertyCount()];

all_schedule_list = Table.getPropertyCount();

for (int i = 0; i < all_schedule_list; i++) {
SoapObject row = (SoapObject) Table
.getProperty(i);
try {
HomeTeamID[i] = row.getProperty(
"HomeTeamId").toString();
HomeTeamName[i] = row.getProperty(
"HomeTeamName").toString();
HomeScore[i] = row.getProperty(
"HomeScore").toString();
AwayTeamId[i] = row.getProperty(
"AwayTeamId").toString();
AwayTeamName[i] = row.getProperty(
"AwayTeamName").toString();
AwayScore[i] = row.getProperty(
"AwayScore").toString();

} catch (NullPointerException e) {

}

}
}
}
}
}
} catch (NullPointerException f) {

} catch (ClassCastException d) {

}
listed_schedule_display.sendEmptyMessage(0);
}
};

final Handler listed_schedule_display = new Handler() {
public void handleMessage(Message msg) {

try {
list_schedule.clear();
populateList_Schedule();
dis_schedule = true;
dialog.dismiss();
} catch (NullPointerException f) {
Toast.makeText(getApplicationContext(),
"web service is down ..try after some time", 2000)
.show();
}
if (tab_chenge == false) {

} else {

list_standing.clear();
mystandings.setVisibility(ListView.INVISIBLE);
myschedule.setVisibility(View.VISIBLE);

populateList_Schedule();

adapter_schedule = new SimpleAdapter(LiMyLijsl.this,
list_schedule, R.layout.schedule, new String[] {
"HomeTeamName", "HomeScore", "Vs", "AwayScore",
"AwayTeamName" }, new int[] {
R.id.home_team_name, R.id.home_score, R.id.vs,
R.id.away_score, R.id.away_team_name });
myschedule.setAdapter(adapter_schedule);
}
}
};

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
// do something on back.
onBackPressed();
return true;
}

return super.onKeyDown(keyCode, event);
}

@Override
public void onBackPressed() {
// do something on back.
Intent i = new Intent(LiMyLijsl.this, Main.class);
startActivity(i);
finish();
}
};
====================================xml==============>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/relativeLayout1" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:background="@drawable/mainback">

<RelativeLayout android:layout_width="fill_parent"
android:gravity="center" android:id="@+id/topbar"
android:layout_height="wrap_content" android:layout_gravity="center"
android:background="@drawable/mainheading">
<Button android:layout_width="wrap_content" android:background="@drawable/back"
android:layout_height="wrap_content" android:layout_margin="5dip"
android:id="@+id/back" />
<TextView android:layout_width="fill_parent" android:id="@+id/top_text"
android:textStyle="bold" android:textSize="20sp" android:gravity="center"
android:layout_gravity="center" android:layout_height="wrap_content"
android:layout_alignBottom="@+id/back" />
</RelativeLayout>

<LinearLayout android:layout_width="fill_parent"
android:layout_below="@+id/topbar" android:id="@+id/top_button"
android:layout_height="wrap_content">

<Button android:text="" android:layout_alignParentTop="true"
android:background="@drawable/standingact" android:id="@+id/btn_mystandings"
android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
<Button android:text="" android:layout_alignParentTop="true"
android:layout_toRightOf="@id/btn_mystandings" android:background="@drawable/schedule"
android:id="@+id/btn_myschedule" android:layout_width="wrap_content"
android:layout_height="wrap_content"></Button>
</LinearLayout>
<LinearLayout android:id="@+id/linearlayout_spinner"
android:layout_below="@id/top_button" android:layout_width="fill_parent"
android:layout_height="60dp">
<Spinner android:id="@+id/spinner_season" android:prompt="@string/hello"
android:layout_width="wrap_content" android:layout_height="wrap_content">
</Spinner>
<Spinner android:id="@+id/spinner_divison"
android:layout_width="wrap_content" android:layout_height="wrap_content">
</Spinner>
</LinearLayout>
<ImageView android:id="@+id/heading_list" android:background="@drawable/linemystand"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_below="@id/linearlayout_spinner">
</ImageView>
<ListView android:layout_width="wrap_content"
android:cacheColorHint="@android:color/transparent" android:focusable="false"
android:fadingEdge="none" android:background="@drawable/mystandingcell"
android:layout_below="@id/heading_list" android:id="@+id/list_standing"
android:layout_height="wrap_content" android:listSelector="@android:color/transparent"></ListView>
<ListView android:layout_width="wrap_content"
android:cacheColorHint="@android:color/transparent" android:focusable="false"
android:fadingEdge="none" android:background="@drawable/mystandingcell"
android:layout_below="@id/heading_list" android:id="@+id/list_schedule"
android:layout_height="wrap_content" android:listSelector="@android:color/transparent"></ListView>
</RelativeLayout>