交換活動我有一個應用程序,它解析RSS饋送到列表中,當我們點擊列表中的項目,它調用其他活動中的WebView顯示RSS源鏈接中的內容:錯誤當機器人
public class ListListener implements OnItemClickListener {
// List item's reference
List<RssItem> listItems;
// Calling activity reference
Activity activity;
public ListListener(List<RssItem> aListItems, Activity anActivity) {
listItems = aListItems;
activity = anActivity;
}
/**
* Start a browser with url from the rss item.
*/
public void onItemClick(AdapterView<?> parent, View view, int pos, long id) {
//Intent i = new Intent(Intent.ACTION_VIEW);
//i.setData(Uri.parse(listItems.get(pos).getLink()));
Intent i = new Intent(activity, WebPageActivity.class);
i.putExtra("LINK", Uri.parse(listItems.get(pos).getLink()));
//Intent intent = new Intent(this, WebPageController(listItems.get(pos).getLink()));
activity.startActivity(i);
}
}
而且從onItemClick它應該調用的WebView活動,以顯示該網頁
public class WebPageActivity extends ActionBarActivity {
private WebView webview;
@Override
protected void onCreate(Bundle savedInstanceState) {
Intent intent = getIntent();
String url = intent.getStringExtra("LINK");
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_web_page);
WebSettings webSettings = webview.getSettings();
webSettings.setJavaScriptEnabled(true);
webview = (WebView) findViewById(R.id.webView1);
webview.getSettings().setJavaScriptEnabled(true);
webview.loadUrl(url);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.web_page, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
有一個在編譯沒有錯誤,但是當我在應用程序中單擊去停止好康活動。 這裏是我的logcat http://pastie.org/9606345
顯示你的logcat,並確定這是因爲你的listItems – k0sh 2014-09-30 04:58:26
1.確保你在Manifest文件中聲明瞭WebPageActivity.java。 2.請發佈logcat輸出 – 2014-09-30 04:58:36
發佈您的logcat錯誤 – appukrb 2014-09-30 05:51:04