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

Fullscreen Activity with titlebar backbutton
How to hide gallery folder and show only the document using ACTION_GET_CONTENT in android?
Android - Include layout from another module
How to create calling info dialog when I get a call, when my app is closed?
Merge Xmpp account with Phonebook name programmatically in adnroid
How to discover printers connected to a wifi?
Android Studio 2.3 sdk manager not open
Android: dlopen() returing daglling pointer for 64 bit architecture
how to rectify this errror “java.lang.RuntimeException: Unable to start activity ComponentInfo”? [duplicate]
Handler not working as planned
Printing on galaxy S5
Override System Pattern/number Lock from Lock Screen Android
VideoView - Listen to RTSP teardown server response
Start activity with provided backstack
Create/delete bitmap image on Button touch in imageView
ANDROID - Google Maps - Cannot “Return Location;” after If Statment

Categories

HOME
service-worker
uml
grok
fabricjs
api
design-patterns
android-studio-2.2
zend-framework
static
components
aws-cli
alsa
pyqt4
banner
special-characters
pattern-matching
arangodb
mql5
angular-dart
gkturnbasedmatch
template-engine
google-maps-autocomplete
microsoft-ocr
spring-async
displaytag
google-api-client
dapper-extensions
surveymonkey
fable-f#
soot
quantlib
failover
ntp
dst
zend-debugger
deltaspike
engine.io
tex
railstutorial.org
opensmpp
plr
vaadin-charts
opencmis
dynamic-linq
openresty
yii2-api
context-switch
semantic-logging
headless
quicktime
libjpeg
rackspace-cloud
pybrain
mathcad
restore
mapxtreme
segment-io
async.js
avspeechsynthesizer
deep
cda
phpwebsocket
uiactionsheet
cycle2
iokit
rate-limiting
amiga
rdflib
skspritenode
snackbar
crowd
structuremap3
spy++
teaspoon
matrix-inverse
jquery-slider
ios8-extension
http-patch
kogrid
kaleidoscope
alice
booksleeve
zope.interface
saleslogix
appjs
httponly
isa-swizzling
entity-attribute-value
landscape-portrait
android-holo-everywhere
presentation-layer
addchild
application-verifier
blender-2.49
lobo-cobra
sqlobject
firefox-3
dsoframer
ifilter
xslcompiledtransform
movieplayer
great-circle

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