I am having trouble with findViewById again in android. My Activity never exits the while loop, because the listview is always null. I already tried rebuilding. I know about the onFinishedInflating method for views, but it doesn't help me in my Activity.
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setContentView(R.layout.list_with_compass);
ListWithCompassView lv = (ListWithCompassView) this.findViewById(R.id.compass_list);
while(lv == null) {
Log.d("waiting", "waiting1");
lv = (ListWithCompassView) this.findViewById(R.id.compass_list);
}
this.setListView();
}
This is the XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/linear_layout_compass" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android">
<karsunke.view.ListWithCompassView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/compass_list">
</karsunke.view.ListWithCompassView>
</LinearLayout>
Add this constructor to your custom view class..
public ListWithCompassView(Context context, AttributeSet attrs) {
super(context, attrs);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With