I know this question is asked several times and I tried to solve according the other solution but in vain. I used customAdapterView with listview. I have also set clickable in the xml. But it's not working.
My question is what's the error that listview is not being clickable?
**Another interesting matter catches my eye that if i start any id name with "list....." during findViewby resoruce id or case - the "l" alphabet automatically becomes captial. Why it happens?
The following portion is inside of onCreate method:-
uddin= getResources().getStringArray(R.array.uddin_name_array);
body=getResources().getStringArray(R.array.uddin_body_array);
prof = getResources().getStringArray(R.array.prof_name_array);
ListView listView= findViewById(R.id.uddinListView);
listView.setClickable(true);
listView.setAdapter(new MyCustomAdapter(this,R.layout.activity_list_view,uddin,prof));
listView.setOnItemClickListener(new AdapterView.OnItemClickListener()
{
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent=new Intent(MainActivity.this,ReadingUddinActivity.class);
startActivity(intent);}
}
);
At last I have found the culprit in the code. It was in the xml code. My Java code worked without error. But it was not clickable because of a rating bar in the custom adapter view.
<RatingBar
android:id="@+id/ratingBar"
style="@style/Widget.AppCompat.RatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:numStars="2" />
When i assign the style as
style="@style/Widget.AppCompat.RatingBar"
list item prevents to become clickable. but if i assign the style as
style="@style/Widget.AppCompat.RatingBar.Small"
or,
style="@style/Widget.AppCompat.RatingBar.Indicator"
it works fine. I don't know why the first one doesn't work. Expert may find the reasons.