求解?Android自定义下拉,为什么只能获取到第一个控件的焦点了
来源:互联网 发布:购物车程序java 编辑:程序博客网 时间:2024/04/29 22:48
我定义了一个下拉效果。但是只点击了他下面第一个控件才有效:
我点击或者触摸“这里是彩期显示区域”才会下拉出历史记录。我现在想要点击下面的红球、篮球选球区域也有效,怎么修改????
java代码:
package com.example.testxiala;import android.app.Activity;import android.os.Bundle;import android.widget.TextView;public class MainActivity extends Activity {private Scrllon_view scrllon_view;private TextView lisi_textview;private TextView main_textview;private TextView main_textview2;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);scrllon_view = (Scrllon_view) findViewById(R.id.main_relative_scrllon_view); lisi_textview = (TextView) findViewById(R.id.lisi_textiview); main_textview = (TextView) findViewById(R.id.main_textiview1); main_textview2 = (TextView) findViewById(R.id.main_textiview2); scrllon_view.setMaxHeight(100);} }
xml布局代码:
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#f6f6f6" android:orientation="vertical" > <RelativeLayout android:layout_width="fill_parent" android:layout_height="52dip" android:layout_gravity="center" android:background="#d80702" > <TextView android:layout_width="wrap_content" android:layout_height="fill_parent" android:gravity="center" android:paddingLeft="15dip" android:text="双色球-普通" android:textColor="#ffffff" android:textSize="18sp" /> </RelativeLayout> <RelativeLayout android:layout_width="fill_parent" android:layout_height="0dip" android:layout_weight="1" android:background="#f6f6f6" android:orientation="vertical" > <TextView android:id="@+id/lisi_textiview" android:layout_width="fill_parent" android:layout_height="80dip" android:background="#517688" android:gravity="center" android:text="历史记录" android:visibility="visible" /> <com.example.testxiala.Scrllon_view android:id="@+id/main_relative_scrllon_view" android:layout_width="match_parent" android:layout_height="fill_parent" > <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#7d7d7d" android:focusable="true" android:orientation="vertical" > <TextView android:id="@+id/main_textiview" android:layout_width="fill_parent" android:layout_height="40dip" android:background="#aabbcc" android:gravity="center" android:text="这里是彩期显示区域" android:textColor="#222222" android:visibility="visible" /> <TextView android:id="@+id/main_textiview1" android:layout_width="fill_parent" android:layout_height="200dip" android:background="#cbacba" android:gravity="center" android:text="这里是选球界面,红球" android:textColor="#d80702" android:visibility="visible" /> <TextView android:id="@+id/main_textiview2" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#abcabc" android:gravity="center" android:text="这里是选球界面,篮球" android:textColor="#d80702" android:visibility="visible" /> </LinearLayout> </com.example.testxiala.Scrllon_view> </RelativeLayout> <!-- 金额,确认选号 --> <View android:layout_width="fill_parent" android:layout_height="1px" android:background="#dedede" /> <RelativeLayout android:layout_width="fill_parent" android:layout_height="52dip" android:background="#f8f8f8" android:orientation="horizontal" > <TextView android:id="@+id/ssq_main_txt_mainConfirm" android:layout_width="80dp" android:layout_height="36dp" android:layout_alignParentRight="true" android:layout_centerVertical="true" android:layout_marginRight="10dp" android:gravity="center" android:text="投注" android:textColor="#222222" android:textSize="16sp" android:textStyle="bold" android:typeface="monospace" /> </RelativeLayout></LinearLayout>
还有我自定义的Scrllon_view
package com.example.testxiala;import android.content.Context;import android.util.AttributeSet;import android.view.MotionEvent;import android.widget.LinearLayout;import android.widget.Scroller;/** * LinearLayout换成RelativeLayout效果也是一样 */public class Scrllon_view extends LinearLayout {Scroller croller;private int moveY = 0;public boolean mEnabled = true;public int maxHeight = 0;public int getMaxHeight() {return maxHeight;}public void setMaxHeight(int maxHeight) {this.maxHeight = maxHeight;}public Scrllon_view(Context context) {super(context);}public Scrllon_view(Context context, AttributeSet set) {super(context, set);setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);setFocusable(true);croller = new Scroller(context);}@Overridepublic boolean onTouchEvent(MotionEvent event) {switch (event.getAction()) {case MotionEvent.ACTION_DOWN:return true;case MotionEvent.ACTION_MOVE:moveY = (int) event.getY();int Y = moveY;if (Y < maxHeight && moveY > 0) {scrollTo(0, -moveY);}break;case MotionEvent.ACTION_UP:int YY = (int) event.getY();if (YY < 100) {scrollTo(0, 0);} else if (YY > 250 && YY < maxHeight) {scrollTo(0, -(maxHeight));}break;default:break;}return super.onTouchEvent(event);}public void startMoveAnim(int startY, int dy, int duration) {croller.startScroll(100, startY, 100, dy, duration);}@Overridepublic boolean onInterceptTouchEvent(MotionEvent ev) {if (mEnabled)return false;return super.onInterceptTouchEvent(ev);}}
代码全部在上面,求解???
0 0
- 求解?Android自定义下拉,为什么只能获取到第一个控件的焦点了
- 为什么我的只能10个过八个 求解
- 【Android自定义View 一】第一个自定义的控件
- Android 中获取EditText控件的焦点以及监听他的内容让焦点自动跳转到下一个EditText控件
- android控件获取焦点
- Android控件获取焦点
- Android 为什么获取到的控件的高度是0
- 后台管理的第一个页面以及实现一个下拉列表自定义控件
- 【Android】如何让一个控件能主动获取到焦点
- 【Android】如何让一个控件能主动获取到焦点
- 解决前台js 传数组数据到后台,后台只能获取数组的第一个值,后面的值都有问题
- android自定义控件焦点问题
- Action从页面获取值只能获取到对象第一个表单值
- Android自定义控件--下拉刷新的实现
- android关于Listview中定义了子控件,子控件和item同时获取焦点的问题
- android如何移除第一个editText的焦点
- getParameterValues只能取到第一个
- Android EditText 获取到焦点
- Linux驱动下的platform总线架构(转)
- 关闭Aero Shake节约系统资源的方法
- 贪心法与动态规划
- Difference between ArrayList and Vector In java
- Codeforces Round #283 (Div. 2) D Tennis Game ——枚举,二分
- 求解?Android自定义下拉,为什么只能获取到第一个控件的焦点了
- oracle中分页查询使用ROWNUM的问题
- 如何查看用户使用情况(最近登入,活跃度。。。)
- Python数据类型 -- 答疑
- MyEclipse中集成和使用Maven的方法
- Android大图片裁剪终极解决方案(上:原理分析)
- 保安过滤器:保安过滤器技术参数及操作方法解析
- Python语句讲解
- 使用libcurl 支持https