用android的WebView 时,从main activity 跳转到新的activity 为什么webview没反应
就是在主activity里,webview可以用,但是跳到另一个activity时webview没有反应求大神。。。问题解决了,犯了个低级的错误,在第二个activity...
就是在主activity里,webview可以用,但是跳到另一个activity时webview没有反应 求大神。。。
问题解决了,犯了个低级的错误,在第二个activity的xml文件中,linearlayout里面少了个android:orientation="vertical",导致webview不正常。
感谢 yanhao_521~ 展开
问题解决了,犯了个低级的错误,在第二个activity的xml文件中,linearlayout里面少了个android:orientation="vertical",导致webview不正常。
感谢 yanhao_521~ 展开
4个回答
2011-07-21
展开全部
public class MyListView3 extends ListActivity implements OnItemClickListener{//继承事件监听接口
// private List<String> data = new ArrayList<String>();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SimpleAdapter adapter = new SimpleAdapter(this,getData(),R.layout.vlist,
new String[],
new int[]);
setListAdapter(adapter);
getListView().setOnItemClickListener(this);//这边不能忘咯
}
private List<Map<String, Object>> getData() {
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
Map<String, Object> map = new HashMap<String, Object>();
map.put("title","新增支出");
map.put("img", R.drawable.car1);
list.add(map);
map = new HashMap<String, Object>();
map.put("title", "我的支出");
return list;
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// FIXME Auto-generated method stub
switch(position){//根据位置进行动作
case 0:
//页面跳转
break;
.
.
.
}
}
}
另外,团IDC网上有许多产品团购,便宜有口碑
// private List<String> data = new ArrayList<String>();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SimpleAdapter adapter = new SimpleAdapter(this,getData(),R.layout.vlist,
new String[],
new int[]);
setListAdapter(adapter);
getListView().setOnItemClickListener(this);//这边不能忘咯
}
private List<Map<String, Object>> getData() {
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
Map<String, Object> map = new HashMap<String, Object>();
map.put("title","新增支出");
map.put("img", R.drawable.car1);
list.add(map);
map = new HashMap<String, Object>();
map.put("title", "我的支出");
return list;
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// FIXME Auto-generated method stub
switch(position){//根据位置进行动作
case 0:
//页面跳转
break;
.
.
.
}
}
}
另外,团IDC网上有许多产品团购,便宜有口碑
展开全部
通过点击WebView上的连接跳转到新Activity中,而不是在原来的Activity中加载,我的代码如下:
m_webView = (WebView)findViewById(R.id.webview);
Intent intent = getIntent();
//设置标题
String titleString = intent.getStringExtra(getString(R.string.http_title));
this.setTitle(titleString);
//加载网页
String urlString = intent.getStringExtra(getString(R.string.http_address));
m_webView.setWebChromeClient(new WebChromeClient());
m_webView.setWebViewClient(new WebViewClient() {
/* (non-Javadoc)
* @see android.webkit.WebViewClient#shouldOverrideUrlLoading(android.webkit.WebView, java.lang.String)
*/
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
Intent intent = new Intent(WebViewActivity.this, WebViewActivity.class);
intent.putExtra(getString(R.string.http_title), url);
intent.putExtra(getString(R.string.http_address), url);
startActivity(intent);
return true;
}
});
m_webView.getSettings().setJavaScriptEnabled(true);
m_webView.loadUrl(urlString);
m_webView = (WebView)findViewById(R.id.webview);
Intent intent = getIntent();
//设置标题
String titleString = intent.getStringExtra(getString(R.string.http_title));
this.setTitle(titleString);
//加载网页
String urlString = intent.getStringExtra(getString(R.string.http_address));
m_webView.setWebChromeClient(new WebChromeClient());
m_webView.setWebViewClient(new WebViewClient() {
/* (non-Javadoc)
* @see android.webkit.WebViewClient#shouldOverrideUrlLoading(android.webkit.WebView, java.lang.String)
*/
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
Intent intent = new Intent(WebViewActivity.this, WebViewActivity.class);
intent.putExtra(getString(R.string.http_title), url);
intent.putExtra(getString(R.string.http_address), url);
startActivity(intent);
return true;
}
});
m_webView.getSettings().setJavaScriptEnabled(true);
m_webView.loadUrl(urlString);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
public class MyListView3 extends ListActivity implements OnItemClickListener{//继承事件监听接口
// private List<String> data = new ArrayList<String>();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SimpleAdapter adapter = new SimpleAdapter(this,getData(),R.layout.vlist,
new String[],
new int[]);
setListAdapter(adapter);
getListView().setOnItemClickListener(this);//这边不能忘咯
}
private List<Map<String, Object>> getData() {
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
Map<String, Object> map = new HashMap<String, Object>();
map.put("title","新增支出");
map.put("img", R.drawable.car1);
list.add(map);
map = new HashMap<String, Object>();
map.put("title", "我的支出");
return list;
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// FIXME Auto-generated method stub
switch(position){//根据位置进行动作
case 0:
//页面跳转
break;
.
.
.
}
}
}
// private List<String> data = new ArrayList<String>();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SimpleAdapter adapter = new SimpleAdapter(this,getData(),R.layout.vlist,
new String[],
new int[]);
setListAdapter(adapter);
getListView().setOnItemClickListener(this);//这边不能忘咯
}
private List<Map<String, Object>> getData() {
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
Map<String, Object> map = new HashMap<String, Object>();
map.put("title","新增支出");
map.put("img", R.drawable.car1);
list.add(map);
map = new HashMap<String, Object>();
map.put("title", "我的支出");
return list;
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// FIXME Auto-generated method stub
switch(position){//根据位置进行动作
case 0:
//页面跳转
break;
.
.
.
}
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
不明白你说的什么··············· activity的转换跟WebView什么关系
更多追问追答
追问
不好意思,没写清楚。
就是在主activity里,webview可以用,但是跳到另一个activity时webview没有反应
追答
WebView只是个组件,在一个Activity中定义在另一个Activity中当然没用了 重新定义一次
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询