刚学习Android开发,纯小白一个,在工作中遇到的一些问题,记录下来,方便以后查阅。
一、Android <ListView> 子条目上有按钮解决优先级问题
在子布局的根目录添加 :
android:descendantFocusability="blocksDescendants" 在项目开发中,可以将子条目上的点击事件写到Adapter中,这样方便很多。
二、解决ScrollView 中套用ListView时直接跳到记录第一条位置的问题
在父布局元素下添加以下属性:
android:focusable="true"
android:focusableInTouchMode="true"
三、在string.xml文件中添加空格用:“ ;”
四、搜索框的实现,(当EditText获取焦点后,弹出的软件盘右下角为搜索按钮)
在EditText下添加以下属性:
android:imeOptions="actionSearch"
android:singleLine="true" 在代码中给搜索按钮添加点击事件 : title_searck.setOnEditorActionListener(new OnEditorActionListener() {
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if(actionId ==EditorInfo.IME_ACTION_SEARCH){
// 点击搜索后隐藏键盘
((InputMethodManager) title_searck.getContext()
.getSystemService(Context.INPUT_METHOD_SERVICE))
.hideSoftInputFromWindow(getCurrentFocus()
.getWindowToken(),InputMethodManager.HIDE_NOT_ALWAYS);
return true;
}
return false;
}
});五、设置了android:theme="@android:style/Theme.NoTitleBar"后页面变成黑色
应该使用android:theme="@android:style/Theme.Light.NoTitleBar"
本文分享了Android开发过程中遇到的一些实用技巧,包括解决ListView子条目按钮优先级问题、ScrollView嵌套ListView滚动定位问题、EditText实现搜索框功能等,对Android开发者具有较高的参考价值。
2万+

被折叠的 条评论
为什么被折叠?



