Skip to content

Snappy1

  • Home
  • Android
  • What
  • How
  • Is
  • Can
  • Does
  • Do
  • Why
  • Are
  • Who
  • Toggle search form

[FIXED] java – Error in displaying data with TextView.setText: Resources$NotFoundException: String resource ID #0x0

Posted on November 11, 2022 By

Solution 1 :

You’re accidentally calling the version of TextView.setText that takes an int resource ID.

You should explicitly convert it to a String:

holder.no_of_sems.setText(Integer.toString(cgpa.getNo_of_sems()));

Problem :

I am getting this exception:

android.content.res.Resources$NotFoundException: String resource ID #0x0

The exception stack trace points to this line in the adapter class:

holder.no_of_sems.setText(cgpa.getNo_of_sems());

This is my adapter class:

public class adapter_cgpa extends RecyclerView.Adapter<adapter_cgpa.Viewholder> {
    ArrayList<POJO> cgpaArrayList;

    public adapter_cgpa(ArrayList<POJO> cgpaArrayList) {
        this.cgpaArrayList = cgpaArrayList;
    }

    @NonNull
    @Override
    public adapter_cgpa.Viewholder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View listitem = LayoutInflater.from(parent.getContext()).inflate(R.layout.recycler_cgpa, parent, false);
        return new Viewholder(listitem);
    }

    @Override
    public void onBindViewHolder(@NonNull adapter_cgpa.Viewholder holder, int position) {
        POJO cgpa= cgpaArrayList.get(position);
        holder.no_of_sems.setText(cgpa.getNo_of_sems());
    }

    @Override
    public int getItemCount() {
        return cgpaArrayList.size();
    }

    public class Viewholder extends RecyclerView.ViewHolder {
        TextView cname, no_of_sems, cgpa, percentage,schemec;
        ImageButton btndelete2;

        public Viewholder(@NonNull View itemView) {
            super(itemView);
            no_of_sems=(TextView)itemView.findViewById(R.id.no_of_sem);
        }
    }
}

This is my POJO class:

public class POJO {
    int no_of_sems;

    public void setNo_of_sems(int no_of_sems) {
        this.no_of_sems = no_of_sems;
    }

    public int getNo_of_sems() {
        return no_of_sems;
    }
}
READ  [FIXED] Request runtime permissions on android
Powered by Inline Related Posts
Android Tags:android, android-recyclerview, android-resources, java

Post navigation

Previous Post: [FIXED] android – How to pass data by Back Button, Kotlin
Next Post: [FIXED] Project with external module issue in android studio 3.6

Related Posts

[FIXED] localization – Why change locale doesn’t work on Android with Android version below Android 7.0 Android
[FIXED] java – How do I search for text within comments and logs in Android Studio Android
[FIXED] module – Android Sygic Embedded SDK doesn’t show a map Android
[FIXED] android – Setting opaque background color on Jetpack Compose Button causes non-uniform coloring (inner rectangle) Android
[FIXED] android – Retrofit – OkHttp Authenticator- How to make other api calls pause till the authenticator completes execution Android
[FIXED] android – LocationServices getFusedLocationProviderClient is not working Android

Archives

  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuándo
  • ¿Cuántas
  • ¿Cuánto
  • ¿Qué
  • Android
  • Are
  • At
  • C'est
  • Can
  • Comment
  • Did
  • Do
  • Does
  • Est-ce
  • Est-il
  • For
  • Has
  • Hat
  • How
  • In
  • Is
  • Ist
  • Kann
  • Où
  • Pourquoi
  • Quand
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welchen
  • Welcher
  • Welches
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Who's
  • Why
  • Wie
  • Will
  • Wird
  • Wo
  • Woher
  • you can create a selvedge edge: You can make the edges of garter stitch more smooth by slipping the first stitch of every row.2022-02-04
  • you really only need to know two patterns: garter stitch

Recent Posts

  • What are the main features of Islamic education?
  • Is the Jeep 4xe worth it?
  • How does the ringer work on cast iron?
  • What is the biggest size interior door?
  • Is blue raspberry an original Jolly Rancher flavor?

Recent Comments

No comments to show.

Copyright © 2023 Snappy1.

Powered by PressBook Grid Dark theme