*This officially works. Thanks for the link.*
*
*
*MyGames.java:
*
package com.lifeofchance.bpt;
import org.json.JSONObject;
import com.androidquery.AQuery;
import android.app.Activity;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
public class MyGames extends Activity{
TextView btnDashboard;
private AQuery listAq;
String[] text = {
"One",
"Two",
"Three",
"Four",
"Five",
"Six",
"Seven",
"Eight",
"Nine",
"Ten"
};
int[] image = {
R.drawable.color_line,
R.drawable.color_line,
R.drawable.color_line,
R.drawable.color_line,
R.drawable.color_line,
R.drawable.color_line,
R.drawable.color_line,
R.drawable.color_line,
R.drawable.color_line,
R.drawable.color_line
};
String[] gameId = {
"12345",
"32165",
"65498",
"98732",
"14789",
"36987"
};
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mygames);
ListView l1 = (ListView) findViewById(R.id.listV);
l1.setAdapter(new MyCustomAdapter(text, image, gameId));
listAq = new AQuery(this);
btnDashboard = (TextView) findViewById(R.id.btnDashboard);
btnDashboard.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent i = new Intent(getApplicationContext(),
DashboardActivity.class);
startActivity(i);
finish();
}
});
}
class MyCustomAdapter extends BaseAdapter {
String[] data_text;
int[] data_image;
String[] data_id;
MyCustomAdapter() {
data_text = null;
data_image = null;
data_id = null;
}
public void setOnClickListener(
android.view.View.OnClickListener onClickListener) {
// TODO Auto-generated method stub
}
MyCustomAdapter(String[] text, int[] image, String[] gameId) {
data_text = text;
data_image = image;
data_id = gameId;
}
public int getCount() {
return data_text.length;
}
public String getItem(int position) {
return null;
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup
parent) {
LayoutInflater inflater = getLayoutInflater();
View row;
row = inflater.inflate(R.layout.mygames_listview, parent,
false);
row.setLongClickable(true);
row.setClickable(true);
row.setFocusable(true);
TextView textview = (TextView)
row.findViewById(R.id.TextView01);
ImageView imageview = (ImageView)
row.findViewById(R.id.ImageView01);
textview.setText(data_text[position]);
imageview.setImageResource(data_image[position]);
row.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Toast.makeText(getApplicationContext(), "clicked",
Toast.LENGTH_LONG).show();
}
});
return (row);
}
}
}
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en