Reputation: 693
I am having this error android.widget.LinearLayout$LayoutParams.
When using this code.
public void modifyingTextViews(){//This sets up a margin for the textviews.
LinearLayout.LayoutParams llp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
llp.setMargins(0, 30, 0, 30);
textview1.setLayoutParams(llp);
textview2.setLayoutParams(llp);
}
It conflicts with my touch methods or my load methods which consists of view flipper with 2 textview and a loader.
From what I understand from a guy with a similar issue is that it is because I am getting this error probably because of the arrangement of the view.
Now My question is how would I be able to tell which is my main view on a view flipper if I have different xmls. Also if there would be a quick fix to the problem that would be appreciated as well.
Upvotes: 2
Views: 557
Reputation: 83303
I can't tell what the issue is without knowing more (your xml code would be a start). Since you asked for an easy fix... I would just define everything in XML. That way everything is organized and you don't have to worry about setting LayoutParams
at runtime.
<ViewFlipper android:id="@+id/flipper"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- layout #1 -->
<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView android:id="@+id/textview1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<!-- layout #2 -->
<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView android:id="@+id/textview2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<!-- fill in the rest here -->
</ViewFlipper>
Of course, this is a hypothetical example and you'll have to write the XML code to get the layout you want, but hopefully this gives you a good idea of where to start. Once you get it all set up, initializing the layout is simply a matter of calling setContentView()
in your onCreate()
method.
Upvotes: 1