So,basically in this as soon as I will click on the image view i should go on the next page that is firstpage .IN this for firstpage I have used recyclerview and for the introduction pge i have used gridadapter.but when I click on the imag view its not getting intented to the next page.I tried all possible sols. ut still the same.plzz help.
this is my introduction.xml code
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/ic_launcher_background"
tools:context=".MainActivity2">
<androidx.cardview.widget.CardView
android:layout_width="199dp"
android:layout_height="199dp"
app:cardElevation="10dp"
app:cardUseCompatPadding="true"
app:contentPadding="10dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.247"
tools:ignore="MissingConstraints"
tools:layout_editor_absoluteX="35dp">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="193dp"
android:layout_height="194dp">
<ImageView
android:id="@+id/imageView4"
android:layout_width="143dp"
android:layout_height="109dp"
tools:layout_editor_absoluteX="7dp"
tools:layout_editor_absoluteY="16dp"
tools:srcCompat="@tools:sample/avatars"
android:onClick="image"/>
<TextView
android:id="@+id/textView15"
android:layout_width="158dp"
android:layout_height="33dp"
android:layout_marginTop="4dp"
android:text="text"
android:textColor="@color/DarkBlue"
android:textSize="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.2"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/imageView4" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
</androidx.constraintlayout.widget.ConstraintLayout>
this is my MainActivity2.java code
public abstract class MainActivity2 extends AppCompatActivity implements ClickedListener {
RecyclerView recycleview1;
List<String> titles;
List<Integer>images;
GridAdapter adapter;
ImageView image;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.intropage);
recycleview1 = findViewById(R.id.recycleview1);
titles = new ArrayList<>();
images = new ArrayList<>();
titles.add("LATEST MOVIES");
titles.add("UPCOMING MOVIES");
titles.add("TRENDING MOVIES");
titles.add("NOW PLAYING");
titles.add("RELEASED MOVIES");
titles.add("HINDI MOVIES");
titles.add("MARATHI MOVIES");
titles.add("ENGLISH MOVIES");
titles.add("TELUGU MOVIES");
titles.add("TAMIL MOVIES");
images.add(R.drawable.latestmovie);
images.add(R.drawable.upcomingmovies);
images.add(R.drawable.trendingmovie);
images.add(R.drawable.nowplaying);
images.add(R.drawable.releasedmovie);
images.add(R.drawable.hindimovies);
images.add(R.drawable.marathimovies);
images.add(R.drawable.englishmovies);
images.add(R.drawable.telugumovies);
images.add(R.drawable.tamilmovies);
adapter = new GridAdapter(this,titles,images,this);
GridLayoutManager gridLayoutManager = new GridLayoutManager(this,2,GridLayoutManager.VERTICAL,false);
recycleview1.setLayoutManager(gridLayoutManager);
recycleview1.setAdapter(adapter);
}
@Override
public void onPictureClicked() {
Intent intent = new Intent(MainActivity2.this, MainActivity1.class);
startActivity(intent);
}
}
this is my GridAdapter.java code
public class GridAdapter extends RecyclerView.Adapter<GridAdapter.ViewHolder> {
List<String>titles;
List<Integer>images;
LayoutInflater inflater;
public GridAdapter(Context context,List<String>titles,List<Integer>images){
this.titles = titles;
this.images = images;
this.inflater = LayoutInflater.from(context);
}
@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = inflater.inflate(R.layout.intoduction,parent,false);
return new ViewHolder(view);
}
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
holder.titles.setText(titles.get(position));
holder.images.setImageResource(images.get(position));
}
@Override
public int getItemCount() {
return titles.size();
}
public class ViewHolder extends RecyclerView.ViewHolder{
TextView titles;
ImageView images;
public ViewHolder(@NonNull View itemView) {
super(itemView);
titles = itemView.findViewById(R.id.textView15);
images = itemView.findViewById(R.id.imageView4);
}
}
}
this is my firstpage.xml code
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/LightGrey"
android:layout_marginTop="5dp"
tools:context=".MainActivity1">
<ImageView
android:id="@+id/imageView3"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_margin="10dp"
tools:srcCompat="@tools:sample/avatars" />
<LinearLayout
android:layout_width="240dp"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:text="Title"
android:textSize="20sp"
android:textStyle="bold">
</TextView>
<TextView
android:id="@+id/text2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_marginTop="-10dp"
android:text="Description"
android:textSize="20sp">
</TextView>
<TextView
android:id="@+id/text3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:text="Ratings"
android:textSize="20sp">
</TextView>
</LinearLayout>
</LinearLayout>