android


viewing gridView items in android


I create a class for a gridview it works correctly and I test it in other parts of app it is working correctly. the Custom layout only contains an imageView in those parts which I test. for an activity I need to use both imageView and textView together and here is the xml code
<?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="wrap_content"
android:weightSum="1"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/imageView3"
android:layout_gravity="center_horizontal"
android:src="#drawable/khattesevom" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Medium Text"
android:id="#+id/textView5"
android:background="#drawable/textblockbio"
android:textColor="#color/colorText"
android:layout_gravity="center_horizontal"
android:padding="5dp" />
</LinearLayout>
My Class's Code:
public class GridLyrics extends BaseAdapter {
private Context mContext;
private final String[] title;
private final int image[];
public GridLyrics(Context context, String[] t, int[] img)
{
mContext = context;
this.title = t;
this.image = img;
}
#Override
public int getCount() {
return title.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) {
View grid;
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if (convertView == null)
{
grid = new View(mContext);
grid = inflater.inflate(R.layout.grid_lyrics, parent, false);
TextView textView = (TextView) grid.findViewById(R.id.textView5);
ImageView imageView = (ImageView)grid.findViewById(R.id.imageView3);
textView.setText(title[position]);
imageView.setImageResource(image[position]);
}
else
{
grid = (View) convertView;
}
return grid;
}
}
and here is the way I use it :
GridView gridView = (GridView) tb2.findViewById(R.id.gridView4);
String[] t = {"Marham", "Onam Mesle Mane", "Mikham", "Door", "To Besh Migi Mariz", "Oraman", "Test"};
int[] img = {R.drawable.ic_khattesevom, R.drawable.ic_khattesevom, R.drawable.ic_khattesevom, R.drawable.ic_khattesevom, R.drawable.ic_khattesevom, R.drawable.ic_khattesevom, R.drawable.ic_khattesevom};
gridView.setAdapter(new GridLyrics(getContext(), t, img));
My problem is in the last row the textView dosn't appear! it shows the picture but not the textView.
the picture of app
I don't know what I can do!
set TextView height to match parent
and remove padding.
change your xml like below.
<?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="wrap_content"
android:weightSum="1"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/imageView3"
android:layout_gravity="center_horizontal"
android:src="#drawable/khattesevom" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Medium Text"
android:id="#+id/textView5"
android:background="#drawable/textblockbio"
android:textColor="#color/colorText"
android:layout_gravity="center_horizontal"
/>
</LinearLayout>
I think it will work for you.
How about this. Change your LinearLayout to ScrollView that way by scrolling down you would be able to get his name

Related Links

Search Android app by part of package name
The specified child already has a parent and click event
How to Detect Lowmemory in android?
Valid XML file gives “failed to parse” error in Android ADT
Android: Update custom surfaceview canvas between two states
Why two method with same name is not possible in Android AIDL interface
This TableLayout layout or its LinearLayout parent is useless how to resolve from this warning
How to get free wallpapers which i can use for my developed Application in Android?
Android - Open / Close Pipes on USB Endpoints
Can't delete the cache in xperia mini
Android 2.2 emulator doesn't react to GPS
Jquery mobile orientation change returns opposite value
Adding glow around the text when pressed
Android Service without any GUI
Is It possible To Pass Constructor Parameters In XML?
Android - Multi Columns ListView

Categories

HOME
google-app-engine
google-cloud-platform
forms
obfuscation
sitecore
javacc
rcloud
32bit-64bit
google-schemas
categorical-data
commonjs
appcelerator-studio
text-mining
java.util.logging
mautic
favicon
foreign-keys
connector
sencha-touch
visual-glitch
ksh
jquery-ias
dataflow-diagram
fat
corpus
rpgle
jaws
vex
xbox
mustache
jmockit
android-sugarorm
gnat-gps
carriage-return
installscript
connection-pool
gdata
railstutorial.org
chef-solo
spring-mvc-test
azure-arm
strftime
fwrite
httrack
xbmc
clarifai
wcftestclient
hammer.js
filehandle
dt
py2neo
change-tracking
smartfoxserver
stax
neon
windows-azure-queues
jtwig
angular-ui-typeahead
gcloud-ruby
fuzzywuzzy
rasterize
oracle-spatial
flock
haskell-warp
botan
umlgraph
appserver
paw
jqmodal
live555
mt4j
printdialog
octal
pclzip
twisted.web
sqlclr
redis-py
correlated-subquery
apache-commons-dbutils
cuteeditor
isapi-extension
web-application-project
google-wave
alsb
sqlobject
great-circle

Resources

Encrypt Message