Annotations and methods can not be recognized in Resources.java

0

My Android App throws a ResourcesNotFoundException.

09-05 21:19:28.456 23667-23667/andi.chroeappclient W/ResourceType: No package identifier when getting value for resource number 0x00000001
09-05 21:19:28.456 23667-23667/andi.chroeappclient D/AndroidRuntime: Shutting down VM
09-05 21:19:28.461 23667-23667/andi.chroeappclient E/AndroidRuntime: FATAL EXCEPTION: main
    Process: andi.chroeappclient, PID: 23667
    android.content.res.Resources$NotFoundException: String resource ID #0x1
        at android.content.res.Resources.getText(Resources.java:339)
        at android.widget.TextView.setText(TextView.java:5496)
        at andi.chroeappclient.TasksArrayAdapter.getView(TasksArrayAdapter.java:40)
        at android.widget.AbsListView.obtainView(AbsListView.java:2365)
...

So I clicked Resources.java:339 and saw this.

TasksArrayAdapter.java:40 is viewHolder.textViewPoints.setText(task.getPoints());

I tried Invalid Caches / Restard, Sync Project with Gradle Files, and Clean and Rebuild Project but none of it helped.

How can I fix this?

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import java.util.ArrayList;

public class TasksArrayAdapter extends ArrayAdapter<Task> {
    public TasksArrayAdapter(@NonNull Context context, int resource, ArrayList<Task> arrayList) {
        super(context, resource);
    }

    @NonNull
    @Override
    public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
        Task task = getItem(position);
        ViewHolder viewHolder;

        if (convertView == null) {
            viewHolder = new ViewHolder();
            convertView = LayoutInflater.from(getContext())
                    .inflate(R.layout.element, parent, false);
            viewHolder.textViewName = convertView.findViewById(R.id.textViewName);
            viewHolder.textViewPoints = convertView.findViewById(R.id.textViewPoints);
            viewHolder.textViewCycle = convertView.findViewById(R.id.textViewCycle);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }


        viewHolder.textViewName.setText(task.getName());
        viewHolder.textViewPoints.setText(task.getPoints());
        viewHolder.textViewCycle.setText(task.getCycle());

        return convertView;
    }

    private static class ViewHolder {
        TextView textViewName;
        TextView textViewPoints;
        TextView textViewCycle;
    }
}
java
android
asked on Stack Overflow Sep 5, 2018 by Andi • edited Sep 5, 2018 by Andi

1 Answer

0

Just change this line

viewHolder.textViewPoints.setText(task.getPoints());

To

viewHolder.textViewPoints.setText(String.valueOf(task.getPoints()));
answered on Stack Overflow Sep 5, 2018 by Parag Pawar

User contributions licensed under CC BY-SA 3.0