Android ScrollView和Achartengine位置和崩溃
我在Android上使用Achartengine,我的布局由一个ScrollView母亲在一个LinearLayout中组成。它包含一个线性布局(即图形)和一些文本视图编辑文本 问题是,如果我在LinearLayout的顶部插入图形,那么程序将运行,但如果我在底部插入图形,在所有textview和edittext之后,程序将崩溃。 为什么? 这是我的XML代码:Android ScrollView和Achartengine位置和崩溃,android,charts,scrollview,achartengine,android-scrollview,Android,Charts,Scrollview,Achartengine,Android Scrollview,我在Android上使用Achartengine,我的布局由一个ScrollView母亲在一个LinearLayout中组成。它包含一个线性布局(即图形)和一些文本视图编辑文本 问题是,如果我在LinearLayout的顶部插入图形,那么程序将运行,但如果我在底部插入图形,在所有textview和edittext之后,程序将崩溃。 为什么? 这是我的XML代码: <?xml version="1.0" encoding="utf-8"?> &l
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true" >
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<!-- android:layout_weight="1" -->
<LinearLayout
android:id="@+id/chart"
android:layout_width="fill_parent"
android:layout_height="200dp"
android:layout_margin="2dp"
android:orientation="horizontal" />
<TextView
android:id="@+id/txtX"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="X: 0"
android:textSize="15sp" >
</TextView>
<TextView
android:id="@+id/txtZ"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="39dp"
android:text="Z: 0"
android:textSize="15sp" />
<TextView
android:id="@+id/txtY"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="35dp"
android:text="Y: 0"
android:textSize="15sp" />
<TextView
android:id="@+id/txtM"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="35dp"
android:text="M: 0"
android:textSize="15sp" />
<TextView
android:id="@+id/txtM2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="35dp"
android:text="M: 0"
android:textSize="15sp" />
<EditText
android:id="@+id/et1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="39dp"
android:ems="10"
android:focusable="false"
android:inputType="textMultiLine" >
</EditText>
</LinearLayout>
</ScrollView>
这在编译器标记错误的initComponents()中调用。
我试图在textview声明之前插入此声明和实例化,唯一改变的是logcat没有标记任何指定的错误,只是在ActivityThread上崩溃。performLaunchActivity(ActivityThread$ActivityClientRecord,Intent)行:1651。我解决了向LinearLayout父级添加ID的问题:
android:id="@+id/general"
我不知道它为什么会起作用,所以我感觉很糟糕,因为我担心它将来是否会起作用。
也许线性布局之间存在冲突。
如果有人理解这个解决方案,可以写在这里
谢谢你的帮助@mango发布崩溃代码:在
initComponents
第112行,logcat表示您正在调用一个视图,而它不一定是这样。当你这样做的时候,在这里发布w/@mango
通知我。我添加了崩溃代码!谢谢大家!:)@我不确定我的标签是否正确。。是吗@一切看起来都很好。。。我很难相信line会抛出错误。你用图表填充的视图是什么意思?你能不能也发布视图字段声明?我添加了图的LinearLayout声明,也许问题是关于带内部LinearLayout的ScrollView@芒果
txtX = (TextView) findViewById(R.id.txtX);
txtY = (TextView) findViewById(R.id.txtY);
txtZ = (TextView) findViewById(R.id.txtZ);
txtM = (TextView) findViewById(R.id.txtM);
txtM2 = (TextView) findViewById(R.id.txtM2);
112 ed1 = (EditText) findViewById(R.id.et1);
for(int i=0; i<camp.length; ++i)
camp[i]=0;
LinearLayout layout = (LinearLayout) findViewById(R.id.chart);
mChartView = ChartFactory.getBarChartView(getBaseContext(), dataset, multiRenderer, BarChart.Type.DEFAULT);
layout.addView(mChartView);
android:id="@+id/general"