-1

I have an ID of a TextView created by a GridView Adapter. Now I want to define my TextView with my ID.

TextView myTextView = view.findViewById(R.id.5);
myTextView.setText("exampleText");
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Konrad Schewe
  • 55
  • 1
  • 7
  • What's the error? – achAmháin Oct 14 '17 at 19:32
  • The error only says it expected a ")" and ";" because it doesnt accept the number – Konrad Schewe Oct 14 '17 at 19:39
  • https://stackoverflow.com/questions/27385604/android-findviewbyid-use-int-at-id-field – achAmháin Oct 14 '17 at 19:45
  • yeah, I have read it but it didnt work the id i got was the same number "5" and not an ID like "R.id.5". I tried intializing the Textview with this id but the app crashed. – Konrad Schewe Oct 14 '17 at 20:07
  • Can you not give it a String value? – achAmháin Oct 14 '17 at 20:07
  • `@Override public View getView(int position, View convertView, ViewGroup parent) { // 1 final String day = days[position]; // 2 if (convertView == null) { final LayoutInflater layoutInflater = LayoutInflater.from(mContext); convertView = layoutInflater.inflate(R.layout.calendarday, null); } final TextView calTag = (TextView)convertView.findViewById(R.id.cal_tag); calTag.setText(day); return convertView; }` – Konrad Schewe Oct 14 '17 at 20:13
  • thats the getView function of my Adapter. Can i set there a new id to the textView? – Konrad Schewe Oct 14 '17 at 20:13

1 Answers1

0

FindViewById method is looking for an id in the inflated view, not creating/assigning a new one. Further more, resource name must begin with a character, you can't name it starting with a number.