如果有人可以请告诉我,我在哪里出错了,这将是非常棒的,因为我已经花了大约2天的时间来试图计算(google)它。基本上我只想在用户点击按钮时将root linearlayout的layout_height从wrap_content更改为fill_parent。
这是我的根main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mycontainer"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#ffff00ff">
<Button android:id="@+id/listBtn"
android:layout_height="38dp"
android:layout_width="wrap_content"
android:text="List"
android:onClick="listBtnHandler"
android:paddingLeft="17dp"
android:paddingRight="17dp"
android:layout_gravity="center"
android:layout_marginRight="10dip"/>
</LinearLayout>
这是我的代码触发错误。
public class MainActivity extends Activity {
/** Called when the activity is first created. */
private Button listBtn;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
listBtn = (Button) findViewById(R.id.listBtn);
}
public void listBtnHandler(View v) {
Log.i("eb", "my button worked");
LinearLayout ll = (LinearLayout) findViewById(R.id.mycontainer);
ll.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
//ViewGroup.LayoutParams params = ll.getLayoutParams();
//params.height=300;
//ll.setLayoutParams(new LinearLayout.LayoutParams(params));
//ll.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT));
}
}
毋庸置疑,我无法在这里工作。
这是控制台输出,它没有显示任何相关内容,因为我找不到源。
Application already deployed. No need to reinstall.
[2011-12-19 15:38:15 - TestApp2] Starting activity com.xxxxx.testapp2.MainActivity on device 015ED9C002020023
[2011-12-19 15:38:15 - TestApp2] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.xxxxx.testapp2/.MainActivity }
[2011-12-19 15:38:16 - TestApp2] Attempting to connect debugger to 'com.xxxx.testapp2' on port 8600
这是我得到的错误,奇怪的是我得到的FrameLayout.class源未找到
// Compiled from FrameLayout.java (version 1.5 : 49.0, super bit)
@android.widget.RemoteViews.RemoteView
public class android.widget.FrameLayout extends android.view.ViewGroup {
// Method descriptor #15 (Landroid/content/Context;)V
// Stack: 4, Locals: 2
public FrameLayout(android.content.Context context);
0 aload_0 [this]
1 aconst_null
2 checkcast android.content.Context [1]
5 aconst_null
6 checkcast android.util.AttributeSet [2]
9 iconst_0
10 invokespecial android.view.ViewGroup(android.content.Context, android.util.AttributeSet, int) [3]
13 new java.lang.RuntimeException [4]
16 dup
17 ldc <String "Stub!"> [5]
19 invokespecial java.lang.RuntimeException(java.lang.String) [6]
22 athrow
Line numbers:
[pc: 0, line: 16]
Local variable table:
[pc: 0, pc: 23] local: this index: 0 type: android.widget.FrameLayout
[pc: 0, pc: 23] local: context index: 1 type: android.content.Context
// Method descriptor #23 (Landroid/content/Context;Landroid/util/AttributeSet;)V
// Stack: 4, Locals: 3
public FrameLayout(android.content.Context context, android.util.AttributeSet attrs);
0 aload_0 [this]
1 aconst_null
2 checkcast android.content.Context [1]
5 aconst_null
6 checkcast android.util.AttributeSet [2]
9 iconst_0
10 invokespecial android.view.ViewGroup(android.content.Context, android.util.AttributeSet, int) [3]
13 new java.lang.RuntimeException [4]
16 dup
17 ldc <String "Stub!"> [5]
19 invokespecial java.lang.RuntimeException(java.lang.String) [6]
22 athrow
Line numbers:
[pc: 0, line: 17]
Local variable table:
[pc: 0, pc: 23] local: this index: 0 type: android.widget.FrameLayout
[pc: 0, pc: 23] local: context index: 1 type: android.content.Context
[pc: 0, pc: 23] local: attrs index: 2 type: android.util.AttributeSet
// Method descriptor #26 (Landroid/content/Context;Landroid/util/AttributeSet;I)V
// Stack: 4, Locals: 4
public FrameLayout(android.content.Context context, android.util.AttributeSet attrs, int defStyle);
0 aload_0 [this]
1 aconst_null
2 checkcast android.content.Context [1]
5 aconst_null
6 checkcast android.util.AttributeSet [2]
9 iconst_0
10 invokespecial android.view.ViewGroup(android.content.Context, android.util.AttributeSet, int) [3]
13 new java.lang.RuntimeException [4]
16 dup
17 ldc <String "Stub!"> [5]
19 invokespecial java.lang.RuntimeException(java.lang.String) [6]
22 athrow
Line numbers:
[pc: 0, line: 18]
Local variable table:
[pc: 0, pc: 23] local: this index: 0 type: android.widget.FrameLayout
[pc: 0, pc: 23] local: context index: 1 type: android.content.Context
[pc: 0, pc: 23] local: attrs index: 2 type: android.util.AttributeSet
[pc: 0, pc: 23] local: defStyle index: 3 type: int
// Method descriptor #30 (I)V
// Stack: 3, Locals: 2
public void setForegroundGravity(int foregroundGravity);
0 new java.lang.RuntimeException [4]
3 dup
4 ldc <String "Stub!"> [5]
6 invokespecial java.lang.RuntimeException(java.lang.String) [6]
9 athrow
Line numbers:
[pc: 0, line: 19]
Local variable table:
[pc: 0, pc: 10] local: this index: 0 type: android.widget.FrameLayout
[pc: 0, pc: 10] local: foregroundGravity index: 1 type: int
// Method descriptor #33 (Landroid/graphics/drawable/Drawable;)Z
// Stack: 3, Locals: 2
protected boolean verifyDrawable(android.graphics.drawable.Drawable who);
0 new java.lang.RuntimeException [4]
3 dup
4 ldc <String "Stub!"> [5]
6 invokespecial java.lang.RuntimeException(java.lang.String) [6]
9 athrow
Line numbers:
[pc: 0, line: 20]
Local variable table:
[pc: 0, pc: 10] local: this index: 0 type: android.widget.FrameLayout
[pc: 0, pc: 10] local: who index: 1 type: android.graphics.drawable.Drawable
// Method descriptor #37 ()V
// Stack: 3, Locals: 1
protected void drawableStateChanged();
0 new java.lang.RuntimeException [4]
3 dup
4 ldc <String "Stub!"> [5]
6 invokespecial java.lang.RuntimeException(java.lang.String) [6]
9 athrow
Line numbers:
[pc: 0, line: 21]
Local variable table:
[pc: 0, pc: 10] local: this index: 0 type: android.widget.FrameLayout
// Method descriptor #39 ()Landroid/widget/FrameLayout$LayoutParams;
// Stack: 3, Locals: 1
protected android.widget.FrameLayout.LayoutParams generateDefaultLayoutParams();
0 new java.lang.RuntimeException [4]
3 dup
4 ldc <String "Stub!"> [5]
6 invokespecial java.lang.RuntimeException(java.lang.String) [6]
9 athrow
Line numbers:
[pc: 0, line: 22]
Local variable table:
[pc: 0, pc: 10] local: this index: 0 type: android.widget.FrameLayout
// Method descriptor #41 (Landroid/graphics/drawable/Drawable;)V
// Stack: 3, Locals: 2
public void setForeground(android.graphics.drawable.Drawable drawable);
0 new java.lang.RuntimeException [4]
3 dup
4 ldc <String "Stub!"> [5]
6 invokespecial java.lang.RuntimeException(java.lang.String) [6]
9 athrow
Line numbers:
[pc: 0, line: 23]
Local variable table:
[pc: 0, pc: 10] local: this index: 0 type: android.widget.FrameLayout
[pc: 0, pc: 10] local: drawable index: 1 type: android.graphics.drawable.Drawable
// Method descriptor #44 ()Landroid/graphics/drawable/Drawable;
// Stack: 3, Locals: 1
public android.graphics.drawable.Drawable getForeground();
0 new java.lang.RuntimeException [4]
3 dup
4 ldc <String "Stub!"> [5]
6 invokespecial java.lang.RuntimeException(java.lang.String) [6]
9 athrow
Line numbers:
[pc: 0, line: 24]
Local variable table:
[pc: 0, pc: 10] local: this index: 0 type: android.widget.FrameLayout
// Method descriptor #46 (II)V
// Stack: 3, Locals: 3
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec);
0 new java.lang.RuntimeException [4]
3 dup
4 ldc <String "Stub!"> [5]
6 invokespecial java.lang.RuntimeException(java.lang.String) [6]
9 athrow
Line numbers:
[pc: 0, line: 25]
Local variable table:
[pc: 0, pc: 10] local: this index: 0 type: android.widget.FrameLayout
[pc: 0, pc: 10] local: widthMeasureSpec index: 1 type: int
[pc: 0, pc: 10] local: heightMeasureSpec index: 2 type: int
// Method descriptor #50 (ZIIII)V
// Stack: 3, Locals: 6
protected void onLayout(boolean changed, int left, int top, int right, int bottom);
0 new java.lang.RuntimeException [4]
3 dup
4 ldc <String "Stub!"> [5]
6 invokespecial java.lang.RuntimeException(java.lang.String) [6]
9 athrow
Line numbers:
[pc: 0, line: 26]
Local variable table:
[pc: 0, pc: 10] local: this index: 0 type: android.widget.FrameLayout
[pc: 0, pc: 10] local: changed index: 1 type: boolean
[pc: 0, pc: 10] local: left index: 2 type: int
[pc: 0, pc: 10] local: top index: 3 type: int
[pc: 0, pc: 10] local: right index: 4 type: int
[pc: 0, pc: 10] local: bottom index: 5 type: int
// Method descriptor #58 (IIII)V
// Stack: 3, Locals: 5
protected void onSizeChanged(int w, int h, int oldw, int oldh);
0 new java.lang.RuntimeException [4]
3 dup
4 ldc <String "Stub!"> [5]
6 invokespecial java.lang.RuntimeException(java.lang.String) [6]
9 athrow
Line numbers:
[pc: 0, line: 27]
Local variable table:
[pc: 0, pc: 10] local: this index: 0 type: android.widget.FrameLayout
[pc: 0, pc: 10] local: w index: 1 type: int
[pc: 0, pc: 10] local: h index: 2 type: int
[pc: 0, pc: 10] local: oldw index: 3 type: int
[pc: 0, pc: 10] local: oldh index: 4 type: int
// Method descriptor #64 (Landroid/graphics/Canvas;)V
// Stack: 3, Locals: 2
public void draw(android.graphics.Canvas canvas);
0 new java.lang.RuntimeException [4]
3 dup
4 ldc <String "Stub!"> [5]
6 invokespecial java.lang.RuntimeException(java.lang.String) [6]
9 athrow
Line numbers:
[pc: 0, line: 28]
Local variable table:
[pc: 0, pc: 10] local: this index: 0 type: android.widget.FrameLayout
[pc: 0, pc: 10] local: canvas index: 1 type: android.graphics.Canvas
// Method descriptor #68 (Landroid/graphics/Region;)Z
// Stack: 3, Locals: 2
public boolean gatherTransparentRegion(android.graphics.Region region);
0 new java.lang.RuntimeException [4]
3 dup
4 ldc <String "Stub!"> [5]
6 invokespecial java.lang.RuntimeException(java.lang.String) [6]
9 athrow
Line numbers:
[pc: 0, line: 29]
Local variable table:
[pc: 0, pc: 10] local: this index: 0 type: android.widget.FrameLayout
[pc: 0, pc: 10] local: region index: 1 type: android.graphics.Region
// Method descriptor #72 (Z)V
// Stack: 3, Locals: 2
public void setMeasureAllChildren(boolean measureAll);
0 new java.lang.RuntimeException [4]
3 dup
4 ldc <String "Stub!"> [5]
6 invokespecial java.lang.RuntimeException(java.lang.String) [6]
9 athrow
Line numbers:
[pc: 0, line: 30]
Local variable table:
[pc: 0, pc: 10] local: this index: 0 type: android.widget.FrameLayout
[pc: 0, pc: 10] local: measureAll index: 1 type: boolean
// Method descriptor #75 ()Z
// Stack: 3, Locals: 1
public boolean getConsiderGoneChildrenWhenMeasuring();
0 new java.lang.RuntimeException [4]
3 dup
4 ldc <String "Stub!"> [5]
6 invokespecial java.lang.RuntimeException(java.lang.String) [6]
9 athrow
Line numbers:
[pc: 0, line: 31]
Local variable table:
[pc: 0, pc: 10] local: this index: 0 type: android.widget.FrameLayout
// Method descriptor #77 (Landroid/util/AttributeSet;)Landroid/widget/FrameLayout$LayoutParams;
// Stack: 3, Locals: 2
public android.widget.FrameLayout.LayoutParams generateLayoutParams(android.util.AttributeSet attrs);
0 new java.lang.RuntimeException [4]
3 dup
4 ldc <String "Stub!"> [5]
6 invokespecial java.lang.RuntimeException(java.lang.String) [6]
9 athrow
Line numbers:
[pc: 0, line: 32]
Local variable table:
[pc: 0, pc: 10] local: this index: 0 type: android.widget.FrameLayout
[pc: 0, pc: 10] local: attrs index: 1 type: android.util.AttributeSet
// Method descriptor #80 (Landroid/view/ViewGroup$LayoutParams;)Z
// Stack: 3, Locals: 2
protected boolean checkLayoutParams(android.view.ViewGroup.LayoutParams p);
0 new java.lang.RuntimeException [4]
3 dup
4 ldc <String "Stub!"> [5]
6 invokespecial java.lang.RuntimeException(java.lang.String) [6]
9 athrow
Line numbers:
[pc: 0, line: 33]
Local variable table:
[pc: 0, pc: 10] local: this index: 0 type: android.widget.FrameLayout
[pc: 0, pc: 10] local: p index: 1 type: android.view.ViewGroup.LayoutParams
// Method descriptor #83 (Landroid/view/ViewGroup$LayoutParams;)Landroid/view/ViewGroup$LayoutParams;
// Stack: 3, Locals: 2
protected android.view.ViewGroup.LayoutParams generateLayoutParams(android.view.ViewGroup.LayoutParams p);
0 new java.lang.RuntimeException [4]
3 dup
4 ldc <String "Stub!"> [5]
6 invokespecial java.lang.RuntimeException(java.lang.String) [6]
9 athrow
Line numbers:
[pc: 0, line: 34]
Local variable table:
[pc: 0, pc: 10] local: this index: 0 type: android.widget.FrameLayout
[pc: 0, pc: 10] local: p index: 1 type: android.view.ViewGroup.LayoutParams
// Method descriptor #84 ()Landroid/view/ViewGroup$LayoutParams;
// Stack: 1, Locals: 1
protected bridge synthetic android.view.ViewGroup.LayoutParams generateDefaultLayoutParams();
0 aload_0 [this]
1 invokevirtual android.widget.FrameLayout.generateDefaultLayoutParams() : android.widget.FrameLayout$LayoutParams [7]
4 areturn
Line numbers:
[pc: 0, line: 3]
Local variable table:
[pc: 0, pc: 5] local: this index: 0 type: android.widget.FrameLayout
// Method descriptor #85 (Landroid/util/AttributeSet;)Landroid/view/ViewGroup$LayoutParams;
// Stack: 2, Locals: 2
public bridge synthetic android.view.ViewGroup.LayoutParams generateLayoutParams(android.util.AttributeSet x0);
0 aload_0 [this]
1 aload_1 [x0]
2 invokevirtual android.widget.FrameLayout.generateLayoutParams(android.util.AttributeSet) : android.widget.FrameLayout$LayoutParams [8]
5 areturn
Line numbers:
[pc: 0, line: 3]
Local variable table:
[pc: 0, pc: 6] local: this index: 0 type: android.widget.FrameLayout
[pc: 0, pc: 6] local: x0 index: 1 type: android.util.AttributeSet
Inner classes:
[inner class info: #11 android/widget/FrameLayout$LayoutParams, outer class info: #9 android/widget/FrameLayout
inner name: #12 LayoutParams, accessflags: 9 public static],
[inner class info: #79 android/view/ViewGroup$LayoutParams, outer class info: #10 android/view/ViewGroup
inner name: #12 LayoutParams, accessflags: 9 public static],
[inner class info: #90 android/widget/RemoteViews$RemoteView, outer class info: #105 android/widget/RemoteViews
inner name: #91 RemoteView, accessflags: 9737 public abstract static]
}
答案 0 :(得分:0)
如果您确定自己正在呼叫LinearLayout
,请在设置新的invalidate()
LinearLayout
上致电LayoutParams
答案 1 :(得分:0)
清理您的项目。经典的。