android


Move to another activity


I have a ListView which has 2 items.
Each one is a ListView.
I just want to move to another Activity when I click an item.
I have this bit of code
public void onBindViewHolder(HomeHolder holder, int position) {
holder.recyclerView.setAdapter(new InHomeAdapter(inflater));
holder.recyclerView.setLayoutManager(new LinearLayoutManager(context,
LinearLayoutManager.HORIZONTAL, false));
holder.recyclerView.addOnItemTouchListener(new
InHomeAdapter.InHomeListener(context, new InHomeAdapter.ClickListener() {
#Override
public void onClick(InHomeAdapter.InHomeHolder holder, View view, int position) {
Intent i = new Intent(this,movie_Detailes.class);
}
});
}
I get a red line under "movie_detailes.class".
How can I do that?
try this
//in adapter constructer
Context context;
public CustomAdapter(Context context){
this.context = context;
}
public void onBindViewHolder(HomeHolder holder, int position) {
holder.recyclerView.setAdapter(new InHomeAdapter(inflater));
holder.recyclerView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false));
holder.recyclerView.addOnItemTouchListener(new InHomeAdapter.InHomeListener(context, new InHomeAdapter.ClickListener() {
#Override
public void onClick(InHomeAdapter.InHomeHolder holder, View view, int position) {
Intent i = new Intent(context, movie_Detailes.class);
}
}));
}
//in adapter constructer
Context context;
public CustomAdapter(Context context){
this.context = context;
}
public void onBindViewHolder(HomeHolder holder, int position) {
holder.recyclerView.setAdapter(new InHomeAdapter(inflater));
holder.recyclerView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false));
holder.recyclerView.addOnItemTouchListener(new InHomeAdapter.InHomeListener(context, new InHomeAdapter.ClickListener() {
#Override
public void onClick(InHomeAdapter.InHomeHolder holder, View view, int position) {
Intent i = new Intent(context, movie_Detailes.class);
context.startActivity(i);
}
}));
}
try these code
//Create constructor of your Adapter class
Context context;
public YourAdapterClass(Context context){
this.context = context;
}
then
public void onBindViewHolder(HomeHolder holder, int position) {
holder.recyclerView.setAdapter(new InHomeAdapter(inflater));
holder.recyclerView.setLayoutManager(new LinearLayoutManager(context,
LinearLayoutManager.HORIZONTAL, false));
holder.recyclerView.addOnItemTouchListener(new
InHomeAdapter.InHomeListener(context, new InHomeAdapter.ClickListener() {
#Override
public void onClick(InHomeAdapter.InHomeHolder holder, View view, int position) {
Intent i = new Intent(context,movie_Detailes.class);
}
});
}

Related Links

Display string with bold letters in Dialog message
How to deactivate a specific USB port on Android device
get captcha from a website
Android: Crop image and Displaying it on ImageView
Display data on graph
PhoneStateListener won't trigger any callback in unit test - Android M +
TextView setGravity not working (ignored) with ViewGroup programmatically
Uploading an Image from React Native to Loopback API with Fetch
Load multiple arrays data from unique XML file in Android Studio
is there any way to conditional Debugging in android studio
confine map to minimum extent
Unable to show popup menu in Adapter in android
How to show progress bar in listview pagination?
Not displaying KML on google earth app
Verify Login using Realm in Android
android plugin development:Activity not shown,and log:Failed resolving bag parent id xxx

Categories

HOME
adal
jpa
time-complexity
forms
alexa-skills-kit
ns-3
toolbox
obfuscation
pclxl
appcelerator
alsa
spin
arangodb
octave
reactive-programming
siddhi
why3
cmdb
naivebayes
libc
intercom
selenium-ide
code-generation
plink
screen-readers
internationalization
package.json
breadth-first-search
inno-download-plugin
imageresizer
displaytag
jquery-callback
iis-express
mql
autodesk-designautomation
panoramas
cognos-bi
database-comparison
hibernate-search
reverse
apiary.io
latitude-longitude
salesforce-communities
lint
recurrent-neural-network
linq-to-objects
cin
urlsession
spring-mvc-test
preloader
outputcache
drupal-theming
procfile
magento-2.0.7
gitlist
spring-integration-sftp
appdomain
boxing
excel-dna
android-instrumentation
parfor
segment-io
i386
delta
avspeechsynthesizer
grass
jaunt-api
highland.js
android-launcher
rdflib
post-commit-hook
easyrtc
xml-namespaces
xml-dsig
maven-scm
qscrollarea
notorm
artemis
solace-mq
kaleidoscope
pclzip
android-icons
cardreader
fb.ui
wimax
intersect
wcf-configuration
failing-tests
fitbounds
multiplatform
globals
object-database
openfaces
dojo-dnd

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