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

ViewPager inside a ScrollView does not scroll correclty
is there any twitter demo example to post photo on twitter with using OAuth in twitter?
how to creating dynamic view in android
How to display a certain parameter of an arraylist into a listview
Android Visualizer (Audio Effects) runtime exception on Ice Cream Sandwich
Android - Paused music automatically restarts to play after answering a phone call
website to debug android apps on actual devices
How to get the data from android? [duplicate]
How to read \uxxxx from json
How to preserve sensitive information in Client-Side-Binary?
Writing and a file reading from the SD Card in Android
Android : swipe between activities using a single resource
Android processing a video, YCrCb frames to video
how to parse a huge json file
Why i am not able to create the round border for specific corner?
When should we use the ID of childs and groups in ExpandableListView?

Categories

HOME
batch-file
notepad++
deep-learning
google-spreadsheet
mysql-workbench
javacc
spring-data-mongodb
pyqt4
vsm
nstableheaderview
spin
google-chrome-app
github-enterprise
xcodebuild
jsonpath
flash-player
null-pointer
jquery-callback
surveymonkey
angularjs-components
amazon-quicksight
android-things
subclass
errbot
bioinformatics
iis-express
userdefaults
livelink
cognos-bi
sql-server-2000
dumpbin
wacom
code-snippets
login-script
android-maps-extensions
reactjs.net
arduino-ide
latitude-longitude
parse-tree
openalpr
release
protein-database
filesystemwatcher
odroid
mcustomscrollbar
datacachefactory
sharp-snmp
chronicle-map
ssrs-2014
x++
phpdbg
libgphoto2
proget
user-defined-fields
google-cse
scalding
azure-cli
opengl-4
edit
ngmaterial
monkey
django-1.10
juice-ui
testrail
redistributable
reporting-services-2012
mta
wso2developerstudio
spreadjs
nio2
dllimport
xvim
intel-c++
jsvc
canvg
dot.js
primitive-types
embedded-fonts
windows-phone-8-sdk
ice-cube
facebook-timeline
windows-98
booksleeve
tree-balancing
iboutlet
apache-whirr
kqueue
screen-size
pylucene
massive
event-receiver
quotation-marks
dataform
instantiationexception
interop-domino
complex-event-processing
contentpresenter
idatareader

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