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

Google Play Sign In black background
nullPointerException recyclerview while passing data to a new class [duplicate]
How to focus on certain part of an image in ImageView based on the xy-coordinates of the image?
Guidance: Want to develop an application which will convert a website into mobile app
Implementing 'FloatingActionButton.Behavior' to stay visible after scrollbar gone
Xamarin testing with TestComplete
How to set different color to some text of a textiew and make that text clickable?
Google maps api authorization error
Mix 2 mp3 files with FFmpeg for adroid
Android: update single views in a Fragment inside TabLayout
Gradle build fail for Affectiva Affdex SDK dependency can not be resolved when opening project on another computer
How to handle an “Internal Server Error” with Android WebView?
Xamarin Android: Exception on designer in search view after adding the iconifiedByDefault.
Push Notification using FCM in android
start android background service on available internet connection?
Android showing dialog on top of another dialog

Categories

HOME
kentico
twitter-bootstrap-3
string
fpga
pagination
spring-data-redis
gradient
accessibility
startup
jsonpath
flatpak
coin3d
asp.net-mvc-viewmodel
identity-management
mapstruct
delphi-xe5
visual-glitch
poedit
exit
tosca
interpreter
expressionengine3
data.stackexchange.com
fragment-backstack
rpgle
google-cast
anki
mailkit
hunspell
numpy-broadcasting
sharepoint-workflow
xdocreport
connection-pool
opensmpp
setup.py
laravel-elixir
postgresql-8.4
android-ibeacon
angular-http
apache-spark-dataset
phpdbg
fwrite
libgphoto2
builder
tinymce-3
convex-optimization
static-cast
skin
jqchart
java-websocket
shinobi
neon
mta
jquery-jscrollpane
i386
appscale
qiime
omniauth-facebook
tracker-enabled-dbcontext
ikiwiki
yajsw
fink
terracotta
microsoft-reporting
evolus-pencil
batik
ms-access-2000
java-security
browserify-shim
administration
deform
named-parameters
ignite-ui
personalization
ray
twitter-bootstrap-rails
clickbank
spring-3
solace-mq
scrypt
modular
merb
http-status-code-410
booksleeve
idn
intersect
pstack
listitem
boost-signals
cgimage
procedures
android-holo-everywhere
u2netdk
listactivity
opml
filesystemobject
visualj#
alsb
software-lifecycle
fdf
blind

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App