last day (14 days later) » 

12:04 PM
1
A: object created for a linear layout inside a fragment returns null value

TeeTrackerwhere and when was setText called? The problem must be fired at getView(). Use setText in onViewCreated(View _view, Bundle _savedInstanceState) and better to replace getView() with _view. Try this dummy code: Added newInstance to DetailFragment: public static Fragment newInstance(Context cxt,...

 
I am calling setText on the implementation of interface onQuestionClicked(of Listfragment - another fragment) created in mainActivity , after creating object for DetailFragment using fragmentmanager as fr and fr.setText(item).
any idea on how to call setText inside onViewCreated ?
 
It could be the problem that you passed data to DetailFragment before DetailFragment has finished building its whole view, this cases getView() with a NULL.
 
thanks for the answer, I searched web for how to pass values to newInstance of DetailFragment from inside the interface implementation of listfragment in mainactivity, but was unsuccessful, need your help.if you require Mainactivity code I will edit my question adding that code. Thanks again.
 
Give more details about your question is better, something like MainActivity etc.
 
yes will give in few moments
Edited adding mainactivity code also
 
12:04 PM
where have you initialized your DetailsFragment?
hi ,, where have you initialized your DetailsFragment?
 
at onQuestionClicked() I have initialized Details fragment
 
u mean:
DetailFragment fragment = (DetailFragment) getFragmentManager()
.findFragmentById(R.id.detail_fragment);
?
 
and your fragment has been declared in layout xml?
 
12:06 PM
ok., let me see
do you use support fragment or nativ fragment?
 
Thanks a lot :)
 
If you use support fragment , try DetailFragment fragment = (DetailFragment) getSupportFragmentManager()
.findFragmentById(R.id.detail_fragment);
aha, you have problem in detailfragment.xml
try this:
<Framelayout
android:layout_width="match_parent"
android:layout_height="match_parent" xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/detailBaseLayout"
> </LinearLayout>
</Framelayout>
 
what is the problem?
 
getView() -> is you linearlyout, and you tried to find detailBaseLayout itself, it was not good.
we give now a container Framelayout, so you try
 
the requirement is I will have linear layout (from xml) inside which i will create two linearlayouts(dynamic) one for populating question (dynamic textviews) and other for populating answeroptions (dynamic Radiobuttons within a radioGroup). Just in case you wanted to know.
 
12:16 PM
yes, I know. so plz change your detailfragment.xml to what I've posted.
 
yes will do
 

last day (14 days later) »