Issue
please why is my Eclipse writing error with getResources()
??
It is writing: The method getResources() is undefined for the type PredmetCursorAdapter
What is wrong with it ?? On all lines with this metode i have that error, but in other classes is all okay
public class PredmetCursorAdapter extends CursorAdapter {
public PredmetCursorAdapter(Context context, Cursor c) {
super(context, c);
// TODO Auto-generated constructor stub
}
@Override
public void bindView(View view, Context context, Cursor cursor) {
// TODO Auto-generated method stub
TextView textViewUlohaName = (TextView) view.findViewById(R.id.nazovPredmetu);
textViewUlohaName.setText(cursor.getString(cursor.getColumnIndex("nazov")));
String den;
int dlzka = Integer.parseInt(cursor.getString(cursor.getColumnIndex("dlzka")));
switch (dlzka)
{
case 0:
den = getResources().getString(R.string.pondelok);
break;
case 1:
den = getResources().getString(R.string.utorok);
break;
case 2:
den = getResources().getString(R.string.streda);
break;
case 3:
den = getResources().getString(R.string.stvrtok);
break;
case 4:
den = getResources().getString(R.string.piatok);
break;
}
TextView textViewUlohaDate = (TextView) view.findViewById(R.id.denPredmetu);
textViewUlohaDate.setText(den);
// upravit hodnotu podla [od - do]
TextView textViewUlohaTime = (TextView) view.findViewById(R.id.casPredmetu);
textViewUlohaTime.setText(cursor.getString(cursor.getColumnIndex("hodina")));
}
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
// TODO Auto-generated method stub
LayoutInflater inflater = LayoutInflater.from(parent.getContext());
View retView = inflater.inflate(R.layout.predmet_simple_list_item, parent,
false);
return retView;
}
public void dni ()
{
}
}
Solution
Try this..
Use context.getResources()
do like that remaining all case
case 0:
den = context.getResources().getString(R.string.pondelok);
break;
Answered By - Hariharan
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.