搜素框的制作
来源:互联网 发布:在淘宝上怎样买东西 编辑:程序博客网 时间:2024/06/01 08:31
浏览器的搜索框的简易制作
首先在浏览器中定义一个简单的布局
一个搜索栏,一个前进的图标,一个WebView
其代码如下:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<EditText
android:id="@+id/et_path"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<ImageView
android:id="@+id/iv_go"
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/jiantou"
/>
<WebView
android:layout_below="@id/et_path"
android:id="@+id/wv"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</RelativeLayout>
之后再mainActivity中写相应的逻辑:
public class MainActivityextends Activity {
private EditText et_path;
private ImageView iv_go;
private WebView wv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_main);
et_path = (EditText) findViewById(R.id.et_path);
iv_go = (ImageView) findViewById(R.id.iv_go);
wv = (WebView) findViewById(R.id.wv);
Intent intent = getIntent();
if (intent != null) {
if (intent.getData() !=null) {
String path = intent.getData().toString();
wv.loadUrl(path);
et_path.setText(path);
}
}
iv_go.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
String path = et_path.getText().toString().trim();
wv.loadUrl(path);
}
});
}
}
- 搜素框的制作
- Javascript制作游戏之一:进度条的制作
- 盗版软件的制作流程及制作周期
- 制作JDebugTool的授权文件制作机
- PHOTOSHOP制作实例-论坛签名的制作
- 浅淡测试夹具制作的制作策略
- 【小制作】WIFI智能窗帘的制作
- 简单的倒计时制作
- 制作自己的控制台
- 位图菜单的制作
- blog的制作
- 浮动层的制作
- 登陆窗体的制作
- 网线的制作
- 安装程序的制作
- 菜单的制作(WINFORMS)
- 绿色按钮的制作
- 玻璃球的制作
- BCGControlBar: 无法解析的外部符号 _xGetSystemMetrics@4
- 关于linux下的TCP 的socket server和client,我的理解
- Lightoj 1107
- 关于忧虑
- 217. Contains Duplicate java
- 搜素框的制作
- LeetCode学习篇一——Counting Bits
- [LeetCode] 131. Palindrome Partitioning
- (转)解决VS2010链接错误:LINK : fatal error LNK1123: 转换到 COFF 期间失败: 文件无效或损坏
- Binder机制(非常好理解)
- Uva227 Puzzle 谜题 (java版本)
- eclipse maven+mybatis+web项目(一)
- Context——Context的使用
- PATB1028:人口普查