android


OnItemClickListener for horizontal gridview


I have designed a view in android which has listview with custom adapter. Now every row item of this listview has horizontal gridview with custom adapter.
My problem is, when I am clicking on any particular item in the horizontal scroll view, I get the position of that item by using
gridview.onItemClickListener
But once I scroll my gridview horizontally, then even if I am clicking on its item my code doesnt goes inside the onclicklistener.
I am not getting whats the issue is. Is my gridview loosing the item focus , once I am scrolling it?
following is my listview adapter :
/**
* Array adapter for main vendor listview
*/
private class VendorMainListAdapter extends ArrayAdapter<String> {
ArrayList<String> VendorNameArrayList = new ArrayList<String>();
private Activity activity;
public VendorMainListAdapter(Activity a, int resource, ArrayList<String> VendorNameArrayList) {
super(a, resource, VendorNameArrayList);
activity = a;
this.VendorNameArrayList = VendorNameArrayList;
}
#Override
public View getView(final int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
final View row = inflater.inflate(R.layout.activity_vendor_list_item, parent, false);
final TextView tvVendorName=(TextView)row.findViewById(R.id.tvVendorNames);
final GridView gvCakeList=(GridView) row.findViewById(R.id.gvCakeList);
tvVendorName.setText(VendorNameArrayList.get(position));
int size=CakeNameArrayList.size();
// Calculated single Item Layout Width for each grid element ....
int width = 150 ;
DisplayMetrics dm = new DisplayMetrics();
HomeScreen.this.getWindowManager().getDefaultDisplay().getMetrics(dm);
float density = dm.density;
int totalWidth = (int) (width * size * density);
singleItemWidth = (int) (width * density);
int height= 100;
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
totalWidth, singleItemWidth);
gvCakeList.setLayoutParams(params);
gvCakeList.setColumnWidth(singleItemWidth);
gvCakeList.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
gvCakeList.setNumColumns(size);
gvCakeList.setHorizontalSpacing(10);
//Here I have set the adapter for the gridview
gvCakeList.setAdapter(new CakeListGridViewAdapter(HomeScreen.this,CakeIdArrayList,CakeNameArrayList,
CakePriceArrayList,CakePicArrayList));
gvCakeList.setSelection(mSelected);
//this is the onitemclicklistener for this gridview
gvCakeList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
Log.e("item clicked ", String.valueOf(i));
}
});
row.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Log.e("oops","you clicked parent");
}
});
return row;
}
}

Related Links

Creating launcher like drag and drop with multiple screens in android
how to show the list of filenames in listview from SDcard in android?
Is Sqlite database persistent for android system apps on Device Wipe / Factory Reset
Android Accessibility - Edit all touch events
Unable to fetch all the contacts from Android
import fizzbuzz not found
Change fragment and navigation drawer state from fragment class
Jsoup HTML parsing and display with multiple views in Android
Variable is accessed from within inner class , needs to be declared final
Share Post only works from Facebook developer
android: how often can I send SMS message
Simple Button on Android Lock Screen with PIN
Null Adapter with Empty List after switching to GSON
On-demand downloading of vector data for mapsforge
Why is this sqlite database column not being created?
How can i write these items for constructor in a for-loop?

Categories

HOME
batch-file
phantom-dsl
porting
rdbms
twig
battery
solaris
switch-statement
3d-reconstruction
spring-session
pkcs#11
minecraft-forge
x-cart
docx
symbol
keytool
forgot-password
digital-signature
sse
sigma.js
oledb
stackexchange
pylons
licensing
entity-relationship-model
angular-translate
event-flow
kudu
angularjs-material
magento-1.9.2.4
sql-server-ce
protein-database
filesystemwatcher
railstutorial.org
loading
diacritics
google-data-api
signals-slots
mcustomscrollbar
comparison-operators
chronicle-map
oim
term
aquamacs
css-transforms
java-websocket
d3-force-directed
renaming
pytables
vulcanize
respondcms
http-status-code-401
blitline
piracy-prevention
toast
character-replacement
toran-proxy
oracle-spatial
roadkill-wiki
rubaxa-sortable
sony-lifelog-api
uncompress
dronekit-android
pyobjc
botan
canvg
fail2ban
document-repository
android-vibration
filesplitting
strawberry-perl
gnumeric
accesscontrolexception
sphinxql
kendo-dataviz
process-explorer
dolby-audio-api
composite-component
mantle
chart-director
dajaxice
koken
stress
virtualpathprovider
hibernateexception
agility.js
google-floodlight
lr
entitydatasource
drawtobitmap
undefined-index
binomial-heap
pos-for-.net
wcf-instancing
dsl-tools
dojo-dnd
fdf
httpcookie
movieplayer
appliance
wspbuilder

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App