Fragment on LinearLayout for button and textview component - android

My current code layout no fragment at the moment,
I need to make a little change on Status(-/Picking/Picked) and Button(Pick-enable/disable) to fragment because I need to keep the data for status and button(enable/disable) always up-to-date/sync to database.
The apps and same piece of data would use by few authorize users. If one of user click on "Pick" button,the rest of user who use the apps,particular Pick button should be disable and status should display "Picking" immediately without refresh the whole layout.
I'm quite new on android apps development, although have some idea/logic to do it but a bit confuse...
Following is my current code...
Hope someone advice me where is the proper place to plant in the "fragment",so I could run a thread behind to get rest service info then display up-to-date value on status and Pick button accordingly immediately without refresh the whole layout .
<LinearLayout
<TextView
android:id="#+id/code"
.../>
<TextView
android:id="#+id/name"
.../>
<TextView
android:id="#+id/qty"
.../>
<TextView
android:id="#+id/status"
.../>
<Button
android:id="#+id/pickButton"
...
android:text="#string/pick" />
/>
.
On the Activity
public class blablaActivity extends ListActivity{
#Override
protected void onStart(){
super.onStart();
new HttpRequestTask().execute();
}
private class HttpRequestTask extends AsyncTask<Void, Void, ArrayList<PickerItemDetail>> {
//private SkuArrayAdapter m_adapter;
#Override
protected ArrayList<PickerItemDetail> doInBackground(Void... params) {
try {
final String url = "http://10.0.2.2:8080/picking";
RestTemplate restTemplate = new RestTemplate();
restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
List<PickerItemDetail> resultList = Arrays.asList(restTemplate.getForObject(url, PickerItemDetail[].class));
ArrayList<PickerItemDetail> pickerList = new ArrayList<PickerItemDetail>();
if(resultList.size()>0){
for(int i=0;i<resultList.size();i++){
PickerItemDetail pickerItemDetail = resultList.get(i);
pickerList.add(pickerItemDetail);
}
}
return pickerList;
} catch (Exception e) {
Log.e("ListFruitActivity:doInBackground", e.getMessage(), e);
}
return null;
}
#Override
protected void onPostExecute(ArrayList<PickerItemDetail> pickerList) {
try{
m_adapter = new SkuArrayAdapter(PickerItemActivity.this,pickerList);
setListAdapter(m_adapter);
}catch(Exception e){
Log.e("ListFruitActivity:onPostExecute", e.getMessage(), e);
}
}
}
}
ArrayAdapter...
public class SkuArrayAdapter extends ArrayAdapter<PickerItemDetail>{
private ArrayList<PickerItemDetail> objects;
private String currentsku;
public SkuArrayAdapter(Context context,ArrayList<PickerItemDetail> objects){
super(context,R.layout.activity_list_fruit,objects);
this.objects = objects;
}
public View getView(int position,View convertView,ViewGroup parent){
// assign the view we are converting to a local variable
View v = convertView;
// first check to see if the view is null. if so, we have to inflate it.
// to inflate it basically means to render, or show, the view.
if (v == null) {
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = inflater.inflate(R.layout.activity_list_fruit, null);
}
/*
* Recall that the variable position is sent in as an argument to this method.
* The variable simply refers to the position of the current object in the list. (The ArrayAdapter
* iterates through the list we sent it)
*
* Therefore, i refers to the current Item object.
*/
PickerItemDetail i = objects.get(position);
if (i != null) {
TextView code = (TextView) v.findViewById(R.id.code);
TextView name = (TextView) v.findViewById(R.id.name);
TextView qty = (TextView) v.findViewById(R.id.qty);
TextView status = (TextView) v.findViewById(R.id.status);
Button btn = (Button) v.findViewById(R.id.pickButton);
//some code....//
}
return v
}

Related

Why is my ListActivity stuck on the /empty element?

I'm trying to use a ListActivity on my Android App but it isn't working the way it should.
Here is my Activity :
public class MainActivity extends ListActivity {
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_terminals_list); //The special layout
TerminalsArrayAdapter adapter = new TerminalsArrayAdapter(this); // A custom adapter
setListAdapter(adapter);
RequestTask task = new RequestTask(adapter); // An Async task
task.execute("/terminals/all");
}
}
Here is my layout :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ListView
android:id="#android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
<TextView
android:id="#android:id/empty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Loading..." />
</LinearLayout>
Here is my custom adapter :
public class TerminalsArrayAdapter extends ArrayAdapter<String[]> {
private Activity mContext;
private ArrayList<String[]> mObjects = new ArrayList<String[]>();
public TerminalsArrayAdapter(Activity context) {
super(context, R.layout.terminals_listview_item);
this.mContext = context;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
View elementView;
if(convertView==null){
LayoutInflater inflater = mContext.getLayoutInflater();
elementView = inflater.inflate(R.layout.terminals_listview_item, parent);
...
// Some things with my view
} else {
elementView = convertView;
}
...
// Some things with my view
return elementView;
}
public void updateTerminals(ArrayList<String[]> newObject){
mObjects.clear();
mObjects.addAll(newObject);
notifyDataSetChanged();
Log.d("TerminalsArrayAdapter", "Dataset Changed !");
}
}
And here is my Async task :
public class RequestTask extends AsyncTask<String, Void, ArrayList<String[]>>{
private final TerminalsArrayAdapter mAdapter;
public RequestTask(TerminalsArrayAdapter adapter) {
mAdapter = adapter;
}
#Override
protected ArrayList<String[]> doInBackground(String... params) {
...
// retrieve some data from my server
return response;
}
#Override
protected void onPostExecute(ArrayList<String[]> response) {
Log.d("response_server","GOT IT !");
mAdapter.updateTerminals(response);
}
}
As I understood, the ListView will be shown only if the adapter is not empty. If it is empty, it will be the TextView which will be displayed.
This is the way my app should work :
The app creates an empty adapter. This will display the "Loading..." TextView
The app creates a new Async task which will retrieve some needed data from my server
When the Async task finishes, it will call the .updateTerminals() method
This method will update the entries of the custom adapter and call notifyDataSetChanged()
The app should now display the ListView with the freshly retrieved data
The steps 1 to 4 are working fine. The problem occurs on step 5 : Even if the data has been updated, my app doesn't refresh the screen to show me the ListView and stays on the "Loading..." TextView.
I tried to figure out what was wrong with my code, but I wasn't able to. I'd love to hear your suggestions/solutions ! Thanks !
PS: Tell me if you need any thing to understand my issue better.
Your ListView height should be match_parent.
Try to play around with setVisibility(View.GONE) and setVisibility(View.VISIBLE) to:
show TextView & hide ListView
show ListView & hide TextView
public class MainActivity extends ListActivity {
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_terminals_list); //The special layout
// create your list with specific method to be able call her many time
// prefer to create then refresh with new data
CreateList(Passanydata);
RequestTask task = new RequestTask(adapter); // An Async task
task.execute("/terminals/all");
}
}
public void CreateList(ArrayList<String[]> response){
TerminalsArrayAdapter adapter = new TerminalsArrayAdapter(this,response); // A custom adapter
setListAdapter(adapter);
}
#Override
protected void onPostExecute(ArrayList<String[]> response) {
Log.d("response_server","GOT IT !");
// after you got your new data , pass it to your list
CreateList(response);
}
public class TerminalsArrayAdapter extends ArrayAdapter<String[]> {
private Activity mContext;
private ArrayList<String[]> mObjects = new ArrayList<String[]>();
public TerminalsArrayAdapter(Activity context,ArrayList<String[]> objects) {
super(context, R.layout.terminals_listview_item);
this.mContext = context;
// when you have your data it will be able to use it here
this.mObjects = objects;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
View elementView;
if(convertView==null){
LayoutInflater inflater = mContext.getLayoutInflater();
elementView = inflater.inflate(R.layout.terminals_listview_item, parent);
...
// Some things with my view
} else {
elementView = convertView;
}
...
// Some things with my view
return elementView;
}
}

Xamarin android: How to get GridView Data Source in android like asp.net

I have a WebService which return user details like User Name, its Date of Birth and Address. I am calling this web service to my android application developed Xamarin c#. But don't know how to show data (bind data) in Grid View. can some one provide sample code or explain how to show data in Grid View.
What you need to do, is to create an adapter for the GridView and axml layout (the view of the components in the GridView). For example, suppose that you want to make a GridView of Tiles with blue background and with a text at the left bottom corner with white color:
tile.axml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/tile_layout"
android:layout_width="30dp"
android:layout_height="30dp"
android:background="#0000FF">
<TextView
android:id="#+id/tile_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:paddingLeft="6dp"
android:paddingBottom="2dp"
android:textColor="#ffffff" />
</RelativeLayout>
TileAdapter.cs
public class TileAdapter : BaseAdapter<BaseTileItem>
{
protected Activity _context = null;
protected List<BaseTileItem> _tileList = new List<BaseTileItem>();
public TileAdapter(Activity context, List<BaseTileItem> tileList)
: base()
{
this._context = context;
this._tileList = tileList;
}
public override BaseTileItem this[int position]
{
get { return this._tileList[position]; }
}
public override long GetItemId(int position)
{
return position;
}
public override int Count
{
get { return this._tileList.Count; }
}
/// Inflates the Tile layout and sets the values
public override Android.Views.View GetView(int position, Android.Views.View convertView, Android.Views.ViewGroup parent)
{
// Get our object for this position
var item = this._tileList[position];
//Try to reuse convertView if it's not null, otherwise inflate it from our item layout
var view = (convertView ??
this._context.LayoutInflater.Inflate(
Resource.Layout.tile,
parent,
false)) as RelativeLayout;
// Find references to each subview in the list item's view
TextView itemText = view.FindViewById<TextView>(Resource.Id.tile_text);
//Assign this item's values to the various subviews
itemText.Text = this._tileList[position].Text;
//Finally return the view
return view;
}
}
}
TileBaseItem.cs
//This is what you retrieve from the webservice
public class BaseTileItem
{
private string _text;
public BaseTileItem(string text)
{
this._text = text;
}
public string Text {
get {return this._text; }
set { this._text = value; }
}
And then in your activity :
private List<BaseTileItem> _usersList;
private TileAdapter _usersAdapter;
private GridView _usersGridView;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
this.SetContentView(Resource.Layout.startactivity);
//inflate all views
InflateViews();
this._usersList = //populate the list with BaseTileItem items
this._usersAdapter = new TileAdapter(this, this._usersList);
//creating the GridView
this._usersGridView = new GridView(this);
this._usersGridView.SetNumColumns(2);
this._usersGridView.SetGravity(GravityFlags.Center);
this._usersGridView.SetPadding(0, 20, 0, 20);
this._usersGridView.SetVerticalSpacing(20);
this._usersGridView.Adapter = this._usersAdapter;
}

Showing graphical instead of strings in an imagelist with title

At the moment I am getting items out of my database and add them to a string called result which I return and set to my TextView:
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.level);
loadDataBase();
int level = Integer.parseInt(getIntent().getExtras().getString("level"));
questions = new ArrayList<Question>();
questions = myDbHelper.getQuestionsLevel(level);
tvQuestion = (TextView) findViewById(R.id.tvQuestion);
i = 0;
String data = getAllItems();
tvQuestion.setText(data);
}
private String getAllItems() {
result = "";
for (i = 0; i<9; i++){
result = result + questions.get(i).getQuestion() + "\n";
}
return result;
// TODO Auto-generated method stub
}
The thing is, all these items also have a title(string) and graphical thumb (string) in the database. I would like to show them as illustrated in the picture below, each with an onclicklistener on it, instead of a boring list of items below eachother. Each item has a picture and title.
Since my beginning programming skills, I am wondering how to do this best, and if you know any good tutorials on it which explain it well?
Thanks!
if i understood your question you need to create a customize an adapter.
Create a new simple class like this which holds an string and a picture
Class ObjectHolder {
int Image;
String Title;
}
and create a getter and setter for this two
then create custom ArrayAdapter
Class CustomArrayAdapter extends ArrayAdapter<ObjectHolder> {
public CustomArrayAdapter(Context C, ObjectHolder[] Arr) {
super(C, R.layout.caa_xml, Arr);
}
#Override
public View getView(int position, View v, ViewGroup parent)
{
View mView = v ;
if(mView == null){
LayoutInflater vi = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mView = vi.inflate(R.layout.cpa_xml, null);
}
TextView text = (TextView) mView.findViewById(R.id.tv_caarow);
ImageView image = (ImageView) mView.findViewById(R.id.iv_caarow);
if(mView != null )
{ text.setText(getItem(position).getText());
image.setImageResource(getItem(position).getImage());
return mView;
}
}
and create caa_xml.xml in res\layout\
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageView
android:id="#+id/iv_caarow"
android:src="#drawable/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/tv_caarow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="15dip"
android:layout_BottomOf="#+id/iv_caarow" />
</RelativeLayout>
and use it like this.
GridView GV= (GridView) findViewById(R.Id.gv); // reference to xml or create in java
ObjectHolder[] OHA;
// assign your array, any ways!
mAdapter CustomArrayAdapter= CustomArrayAdapter(this, OHA);
GridView.setAdapter(mAdapter);

Android, Null Pointer Exception on ListView test code

I am building an app that uses ListView and a custom adapter extending BaseAdapter to handle the data to the ListView. The code is as follows:
newlist.java compiles/runs fine
public class newslist extends Activity {
public static final String tag = "newslist";
ListView listNews;
MyListAdapter listAdapter;
/** Set or Grab the URL */
public static final String parseURL = "http://www.example.com.gr/article.php";
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.newslist);
/** Array Lists */
ArrayList<String> titles = new ArrayList<String>();
ArrayList<String> links = new ArrayList<String>();
ArrayList<String> dates = new ArrayList<String>();
Log.d(newslist.tag, "****** parseURL = " + parseURL);
listNews = (ListView) findViewById(R.id.listNews);
try {
/** Open URL with Jsoup */
Document doc = Jsoup.connect(parseURL).get();
/** Grab classes we want */
Elements pcontent = doc.getElementsByClass("content_title");
Elements pdates = doc.getElementsByClass("content_datecreated_left");
/** Loop for grabbing TITLES within parent element */
for (Element ptitles : pcontent) {
/** Grab Anchors */
Elements ptitle = ptitles.getElementsByTag("a");
for (Element title : ptitle) {
titles.add(title.text());
}
}
/** Loop for grabbing LINKS within parent element */
for (Element plinks : pcontent) {
/** Grab anchors */
Elements plink = plinks.getElementsByTag("a");
for (Element link : plink) {
links.add(link.attr("abs:href")); /** parse absolute address */
}
}
/** Loop for grabbing DATES within parent element */
for (Element pdate : pdates) {
dates.add(pdate.text()) ;
}
//TODO: Regex on Date
//String content: Main Activity Content
int i=0;
int num = titles.size();
String[] printDates = new String[num];
for (i=0; i < num; i++)
{
//substring(25) leaves a space after the date, eg "26/6/2011 "
//content[i] = titles.get(i) + "\n Date: " + dates.get(i).substring(25);
printDates[i] = dates.get(i).substring(25);
}
/** Create an ArrayAdapter, that will actually make the Strings above
* appear in the ListView */
listAdapter = new MyListAdapter(this, titles, dates);
listNews.setAdapter(listAdapter);
} catch (Exception e) {
Log.e(newslist.tag, "****** Failed to Parse URL:" + e.getMessage());
e.printStackTrace();
}
} /*- OnCreate End -*/
} /*- Class End -*/
MyListAdapter.java runs a NPE at line 75:
public class MyListAdapter extends BaseAdapter {
public final static String tag = "MyListAdapter";
public Context context;
public ArrayList<String> title;
public ArrayList<String> date;
public LayoutInflater inflater;
public MyListAdapter(Activity context, ArrayList<String> title, ArrayList<String> date) {
super();
this.context = context;
this.title = title;
this.date = date;
this.inflater = (LayoutInflater) this.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
public int getCount() {
// Auto-generated method stub
return this.title.size();
}
public Object getItem(int position) {
//Auto-generated method stub
return this.title.get(position);
}
public long getItemId(int position) {
// Auto-generated method stub
return position;
}
private static class ViewHolder {
TextView titleView;
TextView dateView;
}
public View getView(int position, View convertView, ViewGroup parent)
{
// Auto-generated method stub
ViewHolder holder;
Log.d(tag, "****** convertView: " + convertView);
if (convertView == null)
{
convertView = inflater.inflate(R.layout.listrow, null);
holder = new ViewHolder();
holder.titleView = (TextView) convertView.findViewById(R.id.listTitle);
holder.dateView = (TextView) convertView.findViewById(R.id.listDate);
convertView.setTag(holder);
}
else
{
holder = (ViewHolder) convertView.getTag();
}
Log.d(tag, "****** Title: " + title.get(position));
Log.d(tag, "****** findViewById: " + convertView.findViewById(R.id.listTitle));
Log.d(tag, "****** holder.titleView: " + holder.titleView);
holder.titleView.setText(title.get(position));
holder.dateView.setText(date.get(position));
//notifyDataSetChanged();
return convertView;
}
}
Line 75 is:
holder.titleView.setText(title.get(position));
However I have tracked the problem to line 62:
holder.titleView = (TextView) convertView.findViewById(R.id.listTitle);
where it seems from my debugging messages that holder.titleView is null
I have tried cleaning/erasing bin folder and rebuilding the project to no avail. I think the problem lies in the View R.id.listTitle not being found. But i have no idea why.
I will also include my two xml files for previewing
newslist.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/title"
android:gravity="center|top"
android:textSize="20dip"
android:textStyle="bold"
android:text="#string/titleNewslist"
/>
<ListView
android:id="#+id/listNews"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
</ListView>
</LinearLayout>
listrow.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:name="#+id/listTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="top|left"
android:textSize="18dip"
android:textStyle="bold"
android:text="TextView">
</TextView>
<TextView
android:name="#+id/listDate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="bottom|right"
android:textSize="12dip"
android:textStyle="bold"
android:textColor="#android:color/white"
android:text="TextView">
</TextView>
</LinearLayout>
You never assign anything to titleView.
You need to do the following in your onCreate() after super.onCreate()
titleView = (TextView) this.getViewById(R.id.listTitle);
Make sure to declare titleView as a field at the top of your class so the rest of your class can access it, if you need to.
Hope this helps!
EDIT:
An important note I just noticed:
android:name="#+id/myName"
is NOT the same as
android:id="#+id/myName"
You need to make sure you declare the ids, or you will not be able to access the layout elements.
I don't really understand the use of ViewHolder.
You should do :
convertView = new YourViewClass();
in this class have 2 fields for both textviews and a onCreate that inflate listRow.xml and find both views by id.
but converview and view holder should not be different and you should not try to pass one view from one component to the other.
Regards,
Stéphane
NullPointerException usually comes, when you have some problems with your XML files. Try to not end your
<TextView
android:name="#+id/listTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="top|left"
android:textSize="18dip"
android:textStyle="bold"
android:text="TextView">
</TextView>
with > and instead of > and
I'm not sure that it's the source of your problem, but it can happen.
Hope it helps.
you are passing the Activity context into the MyListAdapter constructor and assign to the Context object.
change the Activity to Context in constructor and then try it

Android custom listview

Hi i've got a custom listview with a text view and a button in each row.
Im having trouble trying to use the buttons . Each button will fire a different intent. This is the xml file for the list view rows.
<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout
android:id="#+id/widget28"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<Button
android:id="#+id/widget29"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Remind me"
android:layout_alignParentRight="true"
/>
<TextView android:id="#+id/text12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#ff99ccff"
android:text="Text view" />
</RelativeLayout>
Then i have another xml file which simply contains the list view in a linear layout.
This is my custom array class.
public class customArray extends ArrayAdapter<String> {
int resource;
public customArray(Context cont, int _resource, List<String> items) {
super (cont, _resource,items);
resource = _resource;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
RelativeLayout rl;
String prod = getItem(position);
if (convertView == null) {
rl = new RelativeLayout(getContext());
LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
vi.inflate(resource, rl, true);
} else {
rl = (RelativeLayout)convertView;
}
TextView t1 = (TextView)rl.findViewById(R.id.text12);
t1.setText(prod);
Button b1 = (Button)rl.findViewById(R.id.widget29);
return rl;
}
}
Then the final class which gets the data from a database and uses the custom adapter to display the information. Does anyone know how i would call each button?
`public class SatMain extends Activity {
/** Called when the activity is first created.
* #param cont */
#Override
public void onCreate(Bundle savedInstanceState)
{
List<String> results = new ArrayList<String>();
super.onCreate(savedInstanceState);
setContentView(R.layout.satmain);
dbAdapter db = new dbAdapter(this);
// button.setOnClickListener(m);
//---get all titles---
db.open();
db.InsertData();
Cursor c = db.getSat1();
if (c.moveToFirst())
{
do {
String pub = c.getString(c.getColumnIndex(db.KEY_Artist));
String pub1 = c.getString(c.getColumnIndex(db.KEY_Time));
results.add(pub + pub1 );
} while (c.moveToNext());
}
db.close();
ListView listProducts;
customArray ca = new customArray(this, R.layout.button, results);
listProducts = (ListView)findViewById(R.id.list1);
listProducts.setAdapter(ca);
ca.notifyDataSetChanged();
}
}`
In the "getView" method of your adapter, you should set an onClick listener for the button. You can do an anonymous class so that you can refer to the contents of the row in the button. I.e, add the following where you get b1 in your example.
b1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
//create activity based on prod
}
});

Categories

Resources