当前位置: 编程技术>移动开发
本页文章导读:
▪对值变换 对值转换
其实这个看起来更像是java文件 嘿嘿
"key"="value"转换成
<string name="key"> value </string>
public static void main(String[] args) throws IOException {
Scanner fileScanner =
new Scanner(new Fi.........
▪ 调用系统内部 searchUI的根本用法 调用系统内部 searchUI的基本用法
/* 按下键盘即调用搜索框 */ setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL); onSearchRequested();/这里没有重写onSearchRequested()方法,只是单单启动系统search UI.........
▪ test升格测试 test升级测试
test升级测试
http://www.eoeandroid.com/viewthread.php?tid=11708
http://www.androidres.com/index.php/2009/04/13/add-liveupdate-to-android-applications/
http://www.eoeandroid.com/viewthread.php?tid=627
界面
http:/.........
[1]对值变换
来源: 互联网 发布时间: 2014-02-18
对值转换
其实这个看起来更像是java文件 嘿嘿
"key"="value"转换成
<string name="key"> value </string>
public static void main(String[] args) throws IOException {
Scanner fileScanner =
new Scanner(new FileInputStream(args[0]), "utf-8");
Writer writer =
new BufferedWriter(new OutputStreamWriter(new FileOutputStream(
new File(args[1])), "UTF8"));
writer.append("<?xml version=\"1.0\" encoding=\"utf-8\"?> <resources>");
while (fileScanner.hasNextLine()) {
String line = fileScanner.nextLine();
if (line.contains("=")) {
line = line.trim();
line = line.replace("\"", "");
line = line.replace(";", "");
String[] parts = line.split("=");
String nextLine =
"<string name=\"" + parts[0].trim() + "\">"
+ parts[1].trim() + "</string>";
System.out.println(nextLine);
writer.append(nextLine);
}
}
fileScanner.close();
writer.append("</resources>");
writer.close();
}
或者
BufferedReader br = new BufferedReader(new InputStreamReader(
new FileInputStream("c:/messages_en.properties"), "utf-8"));
String line = null;
while ((line = br.readLine()) != null) {
line = line.trim();
if (line.length() > 0) {
String[] parts = line.split(" = ");
System.out.println("<string name=\"" + parts[0] + "\">"
+ parts[1] + "</string>");
}
}
br.close();
[2] 调用系统内部 searchUI的根本用法
来源: 互联网 发布时间: 2014-02-18
调用系统内部 searchUI的基本用法
/* 按下键盘即调用搜索框 */
setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL);
onSearchRequested();/这里没有重写onSearchRequested()方法,只是单单启动系统search UI
当按下搜索按钮,系统就会自动发送Intent,action是Intent.ACTION_SEARCH,可以通过
intent.getStringExtra(SearchManager.QUERY);和intent
.getBundleExtra(SearchManager.APP_DATA);获取数据,具体看下面的Intent参数的传递与获取
在AndroidManifest.xml文件加入
searchable.xml文件
还可以通过类SearchRecentSuggestions来保存搜索记录和清除搜索记录,具体看API demo
Intent参数的传递与获取,下面是转载的
在android利用数据库实现搜索联想功能一文中主要介绍了数据的联想和联想列表的显示,但是没有设计到点击搜索按钮时,activty的跳转和参数的传递功能。下面主要介绍一下activty的调转和参数的传递和获取。在实际的应用中经常用到搜索功能,当用户搜索完毕以后,可能会跳到另外一个activty,并且需要或得之前的activty的一些参数。下面先看一下效果图:
其中第三幅图中的最后一行的内容是第一幅图的activty中传递的参数。
实现的主要代码是:
传递参数的activty:
得到参数的activty:
/* 按下键盘即调用搜索框 */
setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL);
onSearchRequested();/这里没有重写onSearchRequested()方法,只是单单启动系统search UI
当按下搜索按钮,系统就会自动发送Intent,action是Intent.ACTION_SEARCH,可以通过
intent.getStringExtra(SearchManager.QUERY);和intent
.getBundleExtra(SearchManager.APP_DATA);获取数据,具体看下面的Intent参数的传递与获取
在AndroidManifest.xml文件加入
<activity android:name=".SearchActivity"> <intent-filter> <action android:name="android.intent.action.SEARCH" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> <meta-data android:name="android.app.searchable" android:resource="@xml/searchable"/> </activity>
Intent queryIntent = getIntent();
String queryAction = queryIntent.getAction();
/* 取得当按下搜索时的Intent */
if (Intent.ACTION_SEARCH.equals(queryAction))
{
/* 取得所要搜索的字符串 */
String str = queryIntent.getStringExtra(SearchManager.QUERY);
Log.i("msg", str);
query(str);
} searchable.xml文件
<?xml version="1.0" encoding="UTF-8"?> <searchable xmlns:android="http://schemas.android.com/apk/res/android" android:label="@string/search" android:hint="@string/search_hint" android:searchSuggestAuthority="com.mcs.todo" />
还可以通过类SearchRecentSuggestions来保存搜索记录和清除搜索记录,具体看API demo
Intent参数的传递与获取,下面是转载的
在android利用数据库实现搜索联想功能一文中主要介绍了数据的联想和联想列表的显示,但是没有设计到点击搜索按钮时,activty的跳转和参数的传递功能。下面主要介绍一下activty的调转和参数的传递和获取。在实际的应用中经常用到搜索功能,当用户搜索完毕以后,可能会跳到另外一个activty,并且需要或得之前的activty的一些参数。下面先看一下效果图:
其中第三幅图中的最后一行的内容是第一幅图的activty中传递的参数。
实现的主要代码是:
传递参数的activty:
重写onSearchRequested()方法来设置携带的数据
@Override
public boolean onSearchRequested() {
Bundle appDataBundle = new Bundle();
appDataBundle.putString("welcome", "wangjun");
startSearch("搜索", true, appDataBundle, false);
return true;
}得到参数的activty:
TextView textView=(TextView)findViewById(R.id.text1);
TextView textView1=(TextView)findViewById(R.id.text2);
Intent intent = getIntent();
if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
String queryString = intent.getStringExtra(SearchManager.QUERY);
textView.setText("需要搜索的内容是:"+queryString);
final Bundle appData = intent
.getBundleExtra(SearchManager.APP_DATA);
if (appData != null) {
Log.i("welcome", "appDate is not null");
textView1.setText("之前activty传递的参数是:"+appData.getString("welcome"));
} else {
Log.i("welcome", "appDate is null");
}
}
[3] test升格测试
来源: 互联网 发布时间: 2014-02-18
test升级测试
test升级测试 http://www.eoeandroid.com/viewthread.php?tid=11708
http://www.androidres.com/index.php/2009/04/13/add-liveupdate-to-android-applications/ http://www.eoeandroid.com/viewthread.php?tid=627
界面
http://community.htc.com/na/htc-forums/android/f/91/p/2332/8538.aspx
最新技术文章: