我在 framelayout 中放置了三个滚动视图并有三个按钮。每个按钮用于每个滚动视图设置可见性。我在某处有错误,因为滚动视图不滚动。
我的一部分activity_main
<FrameLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="@color/darkoker" >
<ScrollView
android:id="@+id/scroll1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scrollbars="horizontal" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="@+id/coffe"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="fill_vertical"
android:layout_marginLeft="10dp"
android:background="@drawable/coffe"
android:gravity="left"
android:paddingTop="1dp"
android:text="coffe" />
<Button
android:id="@+id/coffe_milk"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginLeft="20dp"
android:background="@drawable/milk_coffe"
android:paddingTop="1dp"
android:text="coffe milk" />
<Button
android:id="@+id/tea"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="fill_vertical"
android:layout_marginLeft="10dp"
android:background="@drawable/tea"
android:gravity="left"
android:text="tea" />
<Button
android:id="@+id/hot_chocolate"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginLeft="20dp"
android:background="@drawable/coffe_cream"
android:paddingTop="1dp"
android:text="hot chocolate" />
</LinearLayout>
</ScrollView>
<ScrollView
android:id="@+id/scroll2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollbars="horizontal" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="@+id/orange"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginLeft="10dp"
android:background="@drawable/juice"
android:text="orange juice" />
<Button
android:id="@+id/coca_colla"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginLeft="20dp"
android:background="@drawable/pepsi"
android:text="coca-cola" />
</LinearLayout>
</ScrollView>
<ScrollView
android:id="@+id/scroll3"
android:layout_width="fill_parent"
android:layout_height="97dp"
android:scrollbars="horizontal" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="@+id/beer"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginLeft="10dp"
android:background="@drawable/beer"
android:text="beer" />
</LinearLayout>
</ScrollView>
</FrameLayout>
和我的一部分MainActivity
............
final ScrollView frameLayout1=(ScrollView)findViewById(R.id.scroll1);
final ScrollView frameLayout2=(ScrollView)findViewById(R.id.scroll2);
final ScrollView frameLayout3=(ScrollView)findViewById(R.id.scroll3);
frameLayout1.setVisibility(View.VISIBLE);
frameLayout2.setVisibility(View.GONE);
frameLayout3.setVisibility(View.GONE);
Button hotDrinks=(Button)findViewById(R.id.hot_drinks);
hotDrinks.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
frameLayout1.setVisibility(View.VISIBLE);
frameLayout2.setVisibility(View.GONE);
frameLayout3.setVisibility(View.GONE);
}
});
Button juices=(Button)findViewById(R.id.juices);
juices.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
frameLayout1.setHorizontalScrollBarEnabled(true);
frameLayout1.setVisibility(View.GONE);
frameLayout2.setVisibility(View.VISIBLE);
frameLayout3.setVisibility(View.GONE);
}
});
Button alcohol=(Button)findViewById(R.id.alcohol);
alcohol.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
frameLayout1.setVisibility(View.GONE);
frameLayout2.setVisibility(View.GONE);
frameLayout3.setVisibility(View.VISIBLE);
}
});
给我看这个error
............
05-29 06:30:36.931: E/StrictMode(3721): null
05-29 06:30:36.931: E/StrictMode(3721): android.app.ServiceConnectionLeaked: Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@40d0f808 that was originally bound here
05-29 06:30:36.931: E/StrictMode(3721): at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:969)
05-29 06:30:36.931: E/StrictMode(3721): at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:863)
05-29 06:30:36.931: E/StrictMode(3721): at android.app.ContextImpl.bindService(ContextImpl.java:1418)
05-29 06:30:36.931: E/StrictMode(3721): at android.app.ContextImpl.bindService(ContextImpl.java:1407)
05-29 06:30:36.931: E/StrictMode(3721): at android.content.ContextWrapper.bindService(ContextWrapper.java:473)
05-29 06:30:36.931: E/StrictMode(3721): at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:157)
05-29 06:30:36.931: E/StrictMode(3721): at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:145)
05-29 06:30:36.931: E/StrictMode(3721): at com.android.emailcommon.service.ServiceProxy.test(ServiceProxy.java:191)
05-29 06:30:36.931: E/StrictMode(3721): at com.android.exchange.ExchangeService$7.run(ExchangeService.java:1850)
05-29 06:30:36.931: E/StrictMode(3721): at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:551)
05-29 06:30:36.931: E/StrictMode(3721): at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:549)
05-29 06:30:36.931: E/StrictMode(3721): at android.os.AsyncTask$2.call(AsyncTask.java:287)
05-29 06:30:36.931: E/StrictMode(3721): at java.util.concurrent.FutureTask.run(FutureTask.java:234)
05-29 06:30:36.931: E/StrictMode(3721): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
05-29 06:30:36.931: E/StrictMode(3721): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
05-29 06:30:36.931: E/StrictMode(3721): at java.lang.Thread.run(Thread.java:856)
05-29 06:31:27.221: E/ActivityThread(3721): Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@40d65a88 that was originally bound here
05-29 06:31:27.221: E/ActivityThread(3721): android.app.ServiceConnectionLeaked: Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@40d65a88 that was originally bound here
05-29 06:31:27.221: E/ActivityThread(3721): at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:969)
05-29 06:31:27.221: E/ActivityThread(3721): at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:863)
05-29 06:31:27.221: E/ActivityThread(3721): at android.app.ContextImpl.bindService(ContextImpl.java:1418)
提前致谢