Android ScrollView的使用
2010-10-12 02:20:00 来源:本站整理1. package com.Aina.Android;
2.
3. import android.app.Activity;
4. import android.os.Bundle;
5. import android.os.Handler;
6. import android.view.KeyEvent;
7. import android.view.View;
8. import android.widget.Button;
9. import android.widget.LinearLayout;
10. import android.widget.ScrollView;
11. import android.widget.TextView;
12.
13. public class Test_ScrollView extends Activity {
14. /** Called when the activity is first created. */
15. private LinearLayout mLayout;
16. private ScrollView sView;
17. private final Handler mHandler = new Handler();
18.
19. @Override
20. public void onCreate(Bundle savedInstanceState) {
21. super.onCreate(savedInstanceState);
22. setContentView(R.layout.main);
23. // 创建一个线性布局
24. mLayout = (LinearLayout) this.findViewById(R.id.LinearLayout);
25. // 创建一个ScrollView对象
26. sView = (ScrollView) this.findViewById(R.id.ScrollView);
27. Button mBtn = (Button) this.findViewById(R.id.Button);
28. mBtn.setOnClickListener(mClickListener);// 添加点击事件监听
29. }
30.
31. public boolean onKeyDown(int keyCode, KeyEvent event){
32. Button b = (Button) this.getCurrentFocus();
33. int count = mLayout.getChildCount();
34. Button bm = (Button) mLayout.getChildAt(count-1);
35.
36. if(keyCode==KeyEvent.KEYCODE_DPAD_UP && b.getId()==R.id.Button){
37. bm.requestFocus();
38. return true;
39. }else if(keyCode==KeyEvent.KEYCODE_DPAD_DOWN && b.getId()==bm.getId()){
40. this.findViewById(R.id.Button).requestFocus();
41. return true;
42. }
Tags:Android ScrollView 使用
编辑录入:爽爽 [复制链接] [打 印]更多精彩
赞助商链接