I did this at my newsviewholder:
public class NewsViewHolder extends RecyclerView.ViewHolder {
View mView;
Context context;
public NewsViewHolder(final View itemView) {
super(itemView);
mView = itemView;
itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(view.getContext(), DetalleFragment.class);
view.getContext().startActivity(intent);
}
});
}
public void setTitular(String titular) {
TextView post_titular = (TextView) mView.findViewById(R.id.titleText);
post_titular.setText(titular);
}
public void setImage(Context ctx, String image){
ImageView post_image = (ImageView) mView.findViewById(R.id.imageView);
Picasso.with(ctx).load(image).into(post_image);
}
}
The problem its when I do onClick in the cardview It throws the next error:
E/AndroidRuntime: FATAL EXCEPTION: main Process: es.laramira.atellez.moroninfo, PID: 5200 android.content.ActivityNotFoundException: Unable to find explicit activity class {es.laramira.atellez.moroninfo/es.laramira.atellez.moroninfo.Fragments.DetalleFragment}; have you declared this activity in your AndroidManifest.xml? at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1805) at android.app.Instrumentation.execStartActivity(Instrumentation.java:1523) at android.app.Activity.startActivityForResult(Activity.java:4224) at android.support.v4.app.BaseFragmentActivityJB.startActivityForResult(BaseFragmentActivityJB.java:50) at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:79) at android.app.Activity.startActivityForResult(Activity.java:4183) at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:859) at android.app.Activity.startActivity(Activity.java:4507) at android.app.Activity.startActivity(Activity.java:4475) at es.laramira.atellez.moroninfo.Models.NewsViewHolder$1.onClick(NewsViewHolder.java:32) at android.view.View.performClick(View.java:5610) at android.view.View$PerformClick.run(View.java:22265) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6077) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
And Ive in my AndroidManifest.xml defined the new activity, but I dont know how to solve this...
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="es.laramira.atellez.moroninfo">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ActivityDetalle"></activity>
</application>
</manifest>
Ive tried a lot of answer found in Stackoverflow and in other sites but I cant solve this...