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

What is preventing Google Play from listing my app for my compatible device?
Images not appearing on Emulator or Phone
Android Color Interpolation
Android toolbar doesn't expand when scrolling up
How to properly save and restore Activity and Fragment status in Android?
using a camera in android (and Parse)
android.widget.EditText cast issue on tablet device
What is the difference between title and display name
Integer in place of Ids and Layouts
Android dragndrop surfaceview
Android - What is outputX/outputY and aspectX/aspectY when crop an image from gallery or camera?
How to implement dynamic page curl in android?
Can I create multiple account with same ip in google play console?
How to make Level as per total no?
when doing query for parseUsers and shoing them in listFragment, while switching fast from fragment to fragment the app crashs
Use a cursorloader from another activity

Categories

HOME
opengl-3
boto3
openpyxl
ibeacon-android
mxgraph
angular-dart
radgridview
mongodb-csharp
keytool
entitymanager
mathprog
dreamweaver
wolframalpha
enterprise-miner
oledb
charles
springfox
systemtime
beta
syntax-highlighting
jquery-multiselect
firebase-analytics
ceylon
eviews
complex-numbers
fstream
biztalk-rule-engine
baidu-map
roblox
apiary.io
apic
cin
jvmti
dcmtk
branching-and-merging
sharp-snmp
chronicle-map
placeholder
avcapturedevice
knime
procfile
snapchat
xbmc
textsum
datamaps
reindex
pair-programming
video-conferencing
dt
rmongo
smartfoxserver
autosar
actor-platform
microstation
latin
qtplugin
greatest-n-per-group
jboss-tools
synonym
cfchart
kango-framework
database-relations
nio2
false-sharing
httpruntime.cache
atan2
vigenere
microsoft-reporting
toolkit
matlab-deployment
shopizer
mass-assignment
dbaccess
trdion2011
verold
dct
terminate
square-bracket
synapse
getopt
jammer
diem
windows-98
qi4j
midlet
veracity
adobe-media-server
subgraph
correlated-subquery
cross-database
w3c-geolocation
aspmenu
spread
scrubyt
contentpresenter

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