My activity extends the ListActivvity and I added the onListItemClick () inside it but listitem click is not getting called.
When I inflate my view and returning that view inside the getView () method listitem click is not getting called but when I did not inflate view and directly call the super method it works fine.
CustomArrayAdapter.java
package com.mobileinsight.presenter.form;
import android.content.Context;
import android.text.Html;
import android.text.method.LinkMovementMethod;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import com.mobileinsight.R;
import com.mobileinsight.common.SimpleMap;
import com.mobileinsight.common.Util;
public class CustomArrayAdapter extends ArrayAdapter<SimpleMap> {
private Product[] objects;
private Context _this;
public CustomArrayAdapter(Context context, int resource, Product[] objects) {
super(context, resource, objects);
this.objects = objects;
this._this = context;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
View rowView = convertView;
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) _this
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
rowView = inflater.inflate(R.layout.list_row, parent, false);
} else {
rowView = convertView;
}
TextView textView = (TextView) rowView.findViewById(R.id.text1);
TextView detailview = (TextView) rowView.findViewById(R.id.text2);
textView.setText("Text 1"));
// textView.setClickable(true);
textView.setMovementMethod(LinkMovementMethod.getInstance());
detailview.setText(objects[position].getDetails());
return rowView; // not working
// return super.getview(); // Working
}
}
list_row.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<TextView
android:id="#+id/text1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_gravity="center_vertical|left"
android:layout_margin="6dip"
android:layout_weight="2"
android:ellipsize="end"
android:gravity="center_vertical|left"
android:singleLine="false"
android:textAppearance="?android:attr/textAppearanceLarge"
/>
<TextView
android:id="#+id/text2"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentRight="true"
android:layout_gravity="center_vertical|right"
android:layout_margin="6dip"
android:layout_weight="0"
android:ellipsize="none"
android:gravity="center_vertical|right"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
Try this code, it may help..
public class CustomArrayAdapter extends ArrayAdapter<SimpleMap>
{
LayoutInflater inflater;
public CustomArrayAdapter(Context context)
{
inflater = LayoutInflater.from(context);
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
View rowView = convertView;
if (convertView == null) {
rowView = inflater.inflate(R.layout.list_row, parent, false);
} else {
rowView = convertView;
}
TextView textView = (TextView) rowView.findViewById(R.id.text1);
TextView detailview = (TextView) rowView.findViewById(R.id.text2);
return rowView;
}
}
Related
my ListView I would like to be about a height of 50dp, but the problem is no matter what value I set the xml layout file too, it automatically makes it much bigger.
Here is my listview layout:
<ListView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/mainListView"
android:layout_below="#+id/"
android:layout_centerHorizontal="true"
android:layout_marginTop="22dp" />
My rowview is
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="?android:attr/listPreferredItemHeight">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/"
android:layout_alignParentTop="false"
android:layout_alignParentLeft="false"
android:layout_alignParentStart="false"
android:textColor="#000000"
android:layout_centerVertical="true"
android:layout_marginLeft="5dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/"
android:layout_alignParentRight="false"
android:layout_alignParentEnd="false"
android:layout_alignParentLeft="false"
android:layout_toRightOf="#+id/"
android:textColor="#000000"
android:layout_centerVertical="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/usernameTextView"
android:layout_below="#+id/"
android:textColor="#666666"
android:layout_toRightOf="#+id/" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/"
android:layout_alignParentTop="false"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true" />
</RelativeLayout>
And my LocalQueueAdapter
package .skyrealm.com;
import android.content.Context;
import android.graphics.Color;
import android.text.Layout;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.squareup.picasso.Picasso;
import java.util.ArrayList;
/**
* Created by RockyFish on 1/24/16.
*/
public class LocalQueueAdapter extends BaseAdapter {
Context context;
LayoutInflater layoutInflater;
ArrayList<ArrayList<String>> localQueueInfo;
public LocalQueueAdapter(Context context, ArrayList<ArrayList<String>> localQueueInfo)
{
this.context = context;
layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
this.localQueueInfo = localQueueInfo;
}
#Override
public int getCount() {
return localQueueInfo.size();
}
#Override
public Object getItem(int position) {
return localQueueInfo.get(position);
}
#Override
public long getItemId(int position) {
return position;
}
public class Holder
{
TextView songNameTextView, artistNameTextView, usernameTextView, numberEditText;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
View rowView = layoutInflater.inflate(R.layout.local_queue_list_item, null);
Holder holder = new Holder();
holder.songNameTextView = (TextView) rowView.findViewById(R.id.songNameTextView);
holder.artistNameTextView = (TextView) rowView.findViewById(R.id.artistNameTextView);
holder.usernameTextView = (TextView) rowView.findViewById(R.id.usernameTextView);
holder.numberEditText = (TextView) rowView.findViewById(R.id.numberTextView);
holder.songNameTextView.setText(" " + localQueueInfo.get(position).get(1));
holder.artistNameTextView.setText(" - " + localQueueInfo.get(position).get(2));
holder.usernameTextView.setText(localQueueInfo.get(position).get(4));
holder.numberEditText.setText(String.valueOf(position + 1) + ".");
if(position == 0)
{
rowView.setBackgroundColor(Color.parseColor("#45B8AC"));
} else if(position == 1)
{
rowView.setBackgroundColor(Color.parseColor("#74E2D5"));
}
return rowView;
}
}
Thank you!
The problem is the inflater. I'm not really sure why. The code below should work for you. Also, you didn't understand how to use ViewHolder (Here is an example and the explanation: https://www.codeofaninja.com/2013/09/android-viewholder-pattern-example.html)
#Override
public View getView(int position, View convertView, ViewGroup parent) {
if(convertView == null) {
View convertView = LayoutInflater.from(context).inflate(R.layout.local_queue_list_item, parent, false);
Holder holder = new Holder();
holder.songNameTextView = (TextView) rowView.findViewById(R.id.songNameTextView);
holder.artistNameTextView = (TextView) rowView.findViewById(R.id.artistNameTextView);
holder.usernameTextView = (TextView) rowView.findViewById(R.id.usernameTextView);
holder.numberEditText = (TextView) rowView.findViewById(R.id.numberTextView);
convertView.setTag(holder);
}
Holder holder = convertView.getTag();
....
return convertView;
}
Yes i know this has been asked many times. I tried every solution provided but ain't working for me. So i am again asking the same question again.
This is my layout file
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="1dp"
android:background="#drawable/view_selector"
android:clickable="true"
android:descendantFocusability="blocksDescendants"
android:orientation="horizontal"
android:padding="3dp">
<TextView android:id="#+id/calcName"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:layout_marginTop="3dp"
android:layout_weight="0.9"
android:gravity="start"
android:clickable="false"
android:focusable="false"
android:focusableInTouchMode="false"
android:textIsSelectable="false"
android:textColor="#FF000000" />
<ImageView android:id="#+id/nextImg"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="end|right"
android:layout_weight="0.1"
android:clickable="false"
android:focusable="false"
android:focusableInTouchMode="false"
android:contentDescription="#string/strImg"
android:src="#drawable/next" />
</LinearLayout>
As you can see i have made every view loose focus even the root view does it.
Then here is my adapter class
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.everythingrf.android.rfcalculators.R;
import java.util.ArrayList;
import java.util.List;
public class CommonListAdapter extends ArrayAdapter<String> {
private Context mContext;
private ArrayList<String> mDataObjects;
private int layout;
public CommonListAdapter(Context context, int resource, ArrayList<String> objects) {
super(context, resource, objects);
mContext = context;
layout = resource;
mDataObjects = objects;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
if (convertView == null) {
holder = new ViewHolder();
LayoutInflater inflater = (LayoutInflater) mContext
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(layout, parent, false);
holder.calcName = (TextView) convertView.findViewById(R.id.calcName);
holder.nextImg = (ImageView) convertView.findViewById(R.id.nextImg);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.calcName.setFocusable(false);
holder.nextImg.setFocusable(false);
holder.calcName.setText(mDataObjects.get(position));
return convertView;
}
public static class ViewHolder{
TextView calcName;
ImageView nextImg;
}
}
Even tried with the adapter
Here is my main class which calls onItemClickListener
myCalcList.setOnItemClickListener(this);
#Override
public void onItemClick(AdapterView<?> adapterView, View view, int pos, long id) {
Log.e("Main","item click");
String selectedCalc = commonList.get(pos);
openSelectedCalc(selectedCalc);
}
Thanks in advance :)
Please just remove android:clickable="true" from row layout,this will work.
As each row is consuming the event which prevent the listview to execute the onItemClick.
If you are extending yout Main from ListActivity in your onCreate method you have to put something like
getListView().setOnItemClickListener(this);
Look I have a example of a custom ListView in my GitHub https://github.com/alvaroroyo/ListViewCustom/tree/master/app/src/main/java/com/example/aroyo/listaliada
I am new to android and facing one very comman problem of listview i googled alot but did'nt found anything usefull for my case.Hope you people show me the right direction.Whenever I am changing my image from "plus" to "tick" on click my last item image also got automatically changed on scroll.
My list_comapare_product XMl :-
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white_color"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:background="#color/white_color"
android:gravity="center_vertical" >
<ImageView
android:id="#+id/img_product"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:src="#drawable/crane" />
<com.mss.skyjack.custom.views.SkyjackCustomTextview
android:id="#+id/tv_product_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:gravity="center"
android:text="test"
android:textAppearance="?android:attr/textAppearanceMedium" />
<ImageView
android:id="#+id/img_plus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:src="#drawable/plus" />
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:background="#color/black_color" />
</LinearLayout>
Here is my Adapter :-
import java.util.List;
import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
public class ComapreProductSelectionAdapter extends BaseAdapter {
Activity activity;
List<SelectorTest> listSelector;
private LayoutInflater mLayoutInflater;
public ComapreProductSelectionAdapter(Activity activity,
List<SelectorTest> listSelector) {
this.activity = activity;
this.listSelector = listSelector;
mLayoutInflater = (LayoutInflater) activity
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
#Override
public int getCount() {
return listSelector.size();
}
#Override
public SelectorTest getItem(int position) {
return listSelector.get(position);
}
#Override
public long getItemId(int position) {
return position;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
final ViewHolder viewHolder;
final int i = position;
final SelectorTest listItem = listSelector.get(position);
if (convertView == null) {
convertView = mLayoutInflater.inflate(
R.layout.list_comapare_product, parent, false);
viewHolder = new ViewHolder();
viewHolder.tvProductName = (TextView) convertView
.findViewById(R.id.tv_product_name);
viewHolder.imgProduct = (ImageView) convertView
.findViewById(R.id.img_product);
viewHolder.imgadd = (ImageView) convertView
.findViewById(R.id.img_plus);
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
viewHolder.imgadd.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
if (viewHolder.imgadd.getDrawable().getConstantState() == activity
.getResources().getDrawable(R.drawable.plus)
.getConstantState()) {
viewHolder.imgadd.setImageResource(R.drawable.tick);
} else {
viewHolder.imgadd.setImageResource(R.drawable.plus);
}
}
});
return convertView;
}
static class ViewHolder {
TextView tvProductName;
ImageView imgProduct, imgadd;
View viewRightLine;
}
}
Thanks.
You need to keep track of which items have been "ticked". I copied your adapter and made necessary changes. You can just copy-paste the code and it should work.
import java.util.List;
import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
public class ComapreProductSelectionAdapter extends BaseAdapter {
Activity activity;
List<SelectorTest> listSelector;
private LayoutInflater mLayoutInflater;
private ArrayList<Integer> tickedItems = new ArrayList<Integer>();
public ComapreProductSelectionAdapter(Activity activity,
List<SelectorTest> listSelector) {
this.activity = activity;
this.listSelector = listSelector;
mLayoutInflater = (LayoutInflater) activity
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
#Override
public int getCount() {
return listSelector.size();
}
#Override
public SelectorTest getItem(int position) {
return listSelector.get(position);
}
#Override
public long getItemId(int position) {
return position;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
final ViewHolder viewHolder;
final int i = position;
final SelectorTest listItem = listSelector.get(position);
if (convertView == null) {
convertView = mLayoutInflater.inflate(
R.layout.list_comapare_product, parent, false);
viewHolder = new ViewHolder();
viewHolder.tvProductName = (TextView) convertView
.findViewById(R.id.tv_product_name);
viewHolder.imgProduct = (ImageView) convertView
.findViewById(R.id.img_product);
viewHolder.imgadd = (ImageView) convertView
.findViewById(R.id.img_plus);
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
viewHolder.imgadd.setTag(position);
viewHolder.imgadd.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
if(tickedItems.contains((Integer)v.getTag()) {
//Already ticked, set to plus
viewHolder.imgadd.setImageDrawable(activity.getResources().getDrawable(R.drawable.plus));
tickedItems.remove((Integer)v.getTag());
} else {
tickedItems.add((Integer)v.getTag());
viewHolder.imgadd.setImageDrawable(activity.getResources().getDrawable(R.drawable.tick));
}
}
});
if(tickedItems.contains(position))
viewHolder.imgadd.setImageDrawable(activity.getResources().getDrawable(R.drawable.tick));
else
viewHolder.imgadd.setImageDrawable(activity.getResources().getDrawable(R.drawable.plus));
return convertView;
}
static class ViewHolder {
TextView tvProductName;
ImageView imgProduct, imgadd;
View viewRightLine;
}
}
As an extra, don't use ImageView.setImageResource() as it is inefficient.
Quote from Android docs about ImageView.setImageReource()
This does Bitmap reading and decoding on the UI thread, which can cause a latency hiccup. If that's a concern, consider using setImageDrawable(android.graphics.drawable.Drawable) or setImageBitmap(android.graphics.Bitmap) and BitmapFactory instead.
1.I want to change the textSize of the items in my listView.
I've a xml file with a button and a listView in a Fragment layout.
I can't change the size of the text's Items.
I tried, in xml, android:textSize and i've searched here but the question is not the same, because normally they haven't a button inside the activity (in my case, a fragment).
My onResume with ArrayAdapter
public void onResume()
{
super.onResume();
ListView listaDeEquipas=(ListView)getView().findViewById(R.id.listaEquipas);
final ArrayAdapter<Equipa> itemsAdapter = new ArrayAdapter<Equipa>(getActivity(), android.R.layout.simple_list_item_1, listaEquipas);
listaDeEquipas.setAdapter(itemsAdapter);
itemsAdapter.notifyDataSetChanged();
listaDeEquipas.setOnItemLongClickListener(new OnItemLongClickListener(){
public boolean onItemLongClick(AdapterView<?> adapterView, View view, int position, long id) {
listaEquipas.remove(position);
itemsAdapter.notifyDataSetChanged();
return false;
}
});
}
My xml code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<Button
android:id="#+id/addEquipa"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:padding="20dip"
android:textColor="#ffffffff"
android:background="#FFCC0000"
android:textStyle="bold"
android:textSize="40sp"
android:text="Inserir Equipa"
android:onClick="true"/>
<ListView
android:id="#+id/listaEquipas"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="10dp"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:layout_gravity="center"
android:fastScrollEnabled="true">
</ListView>
</LinearLayout>
In your ListView adapter, place this line in your getView():
TextView text = (TextView) v.findViewById(android.R.id.text1);
text.setTextSize(30);
You might need to implement a custom adapter for the ListView, like this:
package de.vogella.android.listactivity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
public class myArrayAdapter extends ArrayAdapter<Equipa> {
private final Context context;
private final Equipa[] values;
public myArrayAdapter(Context context,Equipa[] values) {
super(context, android.R.layout.simple_list_item_1, values);
this.context = context;
this.values = values;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = inflater.inflate(android.R.layout.simple_list_item_1, parent, false);
TextView text = (TextView) rowView.findViewById(android.R.id.text1);
text.setTextSize(30);
textView.setText(values[position]); // Set what you want the text to be here
return rowView;
}
}
I try to use GridLayout, to have 4 text views (different string length) being displayed as same size, within same row of TableLayout.
Here is my XML code.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:padding="6dip">
<ImageView
android:id="#+id/color_label"
android:layout_width="12dip"
android:layout_height="fill_parent"
android:layout_marginRight="6dip"
android:background="#ffffff" />
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="1">
<TableRow>
<TextView
android:id="#+id/toptext"
android:gravity="left"
/>
<TextView
android:id="#+id/bottomtext"
android:gravity="right"
/>
</TableRow>
<View android:layout_height="2dip"
android:background="#FF909090" />
<TableRow>
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/myGrid"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dp"
android:verticalSpacing="10dp"
android:horizontalSpacing="10dp"
android:numColumns="4"
/>
</TableRow>
</TableLayout>
</LinearLayout>
and here are my adapter code for the row of list view.
package org.yccheok.jstock.widget;
import java.util.ArrayList;
import org.yccheok.jstock.activity.R;
import org.yccheok.jstock.portfolio.Order;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.TextView;
public class OrderAdapter extends ArrayAdapter<Order> {
private ArrayList<Order> items;
public OrderAdapter(Context context, int textViewResourceId, ArrayList<Order> items) {
super(context, textViewResourceId, items);
this.items = items;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
if (v == null) {
LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.custom_row_view, null);
}
Order o = items.get(position);
if (o != null) {
TextView tt = (TextView) v.findViewById(R.id.toptext);
TextView bt = (TextView) v.findViewById(R.id.bottomtext);
if (tt != null) {
tt.setText(o.getOrderName());
}
if (bt != null) {
bt.setText(o.getOrderStatus());
}
}
GridView grid = (GridView) v.findViewById(R.id.myGrid);
grid.setAdapter(new ImageAdapter(this.getContext()));
return v;
}
private class ImageAdapter extends BaseAdapter {
private Context mContext;
public ImageAdapter(Context c) {
mContext = c;
}
public int getCount() {
return 4;
}
public Object getItem(int position) {
return null;
}
public long getItemId(int position) {
return 0;
}
// create a new ImageView for each item referenced by the Adapter
public View getView(int position, View convertView, ViewGroup parent) {
TextView textview = new TextView(mContext);
textview.setText("Hello");
return textview;
}
}
}
However, I am getting pretty strange result. (Highlight in red)
What my expectation is something like this. (Highlight in red)
Does this mean I can't use GridLayout in the row of TableLayout?
I don't know if this is the source of your problem or not, but I believe that all elements in a TableRow should be given a column number (e.g. android:layout_column="1").