public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.shuping);
db=new DB(this);
DisplayMetrics dm=new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
widthp=dm.widthPixels;
heightp=dm.heightPixels;//这里有问题
// ScrollView001=(ScrollView)this.findViewById(R.id.scroll001);
// Linear01 =(LinearLayout)this.findViewById(R.id.Linear01);
// Linear01.removeAllViews();
final Button btn01=(Button) this.findViewById(R.id.btn01);
final Button btn02=(Button) this.findViewById(R.id.btn02);
final Button btn03=(Button) this.findViewById(R.id.btn03);
final Button btn04=(Button) this.findViewById(R.id.btn04);
为啥加上这个调试就出错,去掉就没问题,能够不能够在onCreate方法中操作这个LinearLayout,或者ScrollView001还是什么问题,为啥添加任意一个就出错????????????
// ScrollView001=(ScrollView)this.findViewById(R.id.scroll001);
// Linear01 =(LinearLayout)this.findViewById(R.id.Linear01);
// Linear01.removeAllViews();
布局这样大概这样 <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<HorizontalScrollView android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:scrollbarAlwaysDrawHorizontalTrack="false"
android:id="@+id/scroll001"
>
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/Linear01">
</LinearLayout>
</HorizontalScrollView>
super.onCreate(savedInstanceState);
setContentView(R.layout.shuping);
db=new DB(this);
DisplayMetrics dm=new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
widthp=dm.widthPixels;
heightp=dm.heightPixels;//这里有问题
// ScrollView001=(ScrollView)this.findViewById(R.id.scroll001);
// Linear01 =(LinearLayout)this.findViewById(R.id.Linear01);
// Linear01.removeAllViews();
final Button btn01=(Button) this.findViewById(R.id.btn01);
final Button btn02=(Button) this.findViewById(R.id.btn02);
final Button btn03=(Button) this.findViewById(R.id.btn03);
final Button btn04=(Button) this.findViewById(R.id.btn04);
为啥加上这个调试就出错,去掉就没问题,能够不能够在onCreate方法中操作这个LinearLayout,或者ScrollView001还是什么问题,为啥添加任意一个就出错????????????
// ScrollView001=(ScrollView)this.findViewById(R.id.scroll001);
// Linear01 =(LinearLayout)this.findViewById(R.id.Linear01);
// Linear01.removeAllViews();
布局这样大概这样 <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<HorizontalScrollView android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:scrollbarAlwaysDrawHorizontalTrack="false"
android:id="@+id/scroll001"
>
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/Linear01">
</LinearLayout>
</HorizontalScrollView>
解决方案 »
- 关于android中的onTouch 和 onClick 等事件
- androidpn可以用于两个手机之间的沟通吗
- onCreate的savedInstanceState为何一直是null?
- View.GONE not work ,help!
- android模拟器如何测试多点触控呢?
- 怎样修改系统自带的程序,比如Launcher!!!求详细方法
- 求助,调用相机将图片显示到一个imageview上,用的系统自带相机可以得到正常照片,但是调用其他相机如360相机则图片特别不清晰。
- 有没有这样的方法String.format("aaa%d, bbb%d, ccc%d", "我","你", “他”);
- 学习android新手,实例中学习,最近在做这个例子,想通过例子掌握和学习,通过webservice读取mssql数据库记录并显示,遇到了问题,请帮忙!
- 为什么MediaPlayer pause();后会将之前新建的线程重新new一个?
- android wifi问题 各位大仙 大牛 帮帮忙啊!!
- 请问我该如何用json解析一下例子
你说的重启就没问题了,可能是eclipse解析工程时出的问题,有时候eclipse就会抽风。
重启eclipse或者先删除工程,再import工程也能解决问题。