Android剪貼板復制內容可以粘貼到任何地方,對于一些字典、翻譯工具和其他應用程序具有很高的使用價值,那么Androi開發中道詞典的實現方法大家都清楚嗎?下面就讓武林技術頻道小編帶你一起來了解一下吧!
首先看程序界面如下!
1、布局文件:
android:layout_width="150px"
android:layout_height="40px"
android:layout_x="5px"
android:layout_y="32px"
android:textSize="18sp" />
android:layout_width="300px"
android:layout_height="330px"
android:layout_x="7px"
android:layout_y="90px"
android:focusable="false" />
2、修改MainActivity:
private void SetView() {
btnSearch = (Button) findViewById(R.id.btnsearch);
btnClear = (Button) findViewById(R.id.btnclear);
editText = (EditText) findViewById(R.id.editText);
reswebView = (WebView) findViewById(R.id.reswebView);
btnSearch.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
String strUri = editText.getText().toString();
strUri = strUri.trim();
if (strUri.length() == 0) {
Toast.makeText(getApplicationContext(), "請輸入查詢字符", 1).show();
} else {
String strURL = "http://dict.youdao.com/m/search?keyfrom=dict.mindex&q=" + strUri;
reswebView.loadUrl(strURL);
}
}
});
btnClear.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
editText.setText("");
}
});
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
SetView();
}
}
3、在清單文件中添加網絡訪問權限:
運行程序即可!
上文是關于Androi開發中道詞典的實現方法,相信大家都有了一定的了解,想要了解更多的技術信息,請繼續關注武林技術頻道吧!
新聞熱點
疑難解答