I have a listView in my application and at some point during the execution, I want to highlight a specific row. I found some examples but I keep getting errors. Here is my code:
public void animate(int pos){ //pos:position of the row in the list
lv1=(ListView)findViewById(R.id.listView1);
Animation animation = AnimationUtils.loadAnimation(getBaseContext(), R.anim.scale);
((View)lv1.getItemAtPosition(pos)).startAnimation(animation);
}
and scale.xml
<?xml version="1.0" encoding="utf-8"?>
If anyone can help with this I would really appreciate it.
EDIT: I want to give an additional information I just found out. I get a NullPointerException when I run the code. Following line causes the exception
((View)lv1.getItemAtPosition(pos))
I cannot get the items in listView. I changed my program as follows:
public void animate(int pos){ //pos:position of the row in the list
lv1=(ListView)findViewById(R.id.listView1);
View v=lv1.getChildAt(pos);
Toast.makeText(getBaseContext(),Boolean.toString((v==null)),Toast.LENGTH_SHORT).show();
}
It always displays "true". I didn't understand where the problem is stemming from.
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)