我正在嘗試將主要活動的變量(url_1)值傳遞給webview。但是,當我點擊按鈕應用程序崩潰。我也使用putExtra,但它不起作用。請看下面的代碼。當webview打開時,Android應用程序崩潰
public class CustomAdapter extends BaseAdapter{
String [] result;
Context context;
int [] imageId;
private static LayoutInflater inflater=null;
public CustomAdapter(MainActivity mainActivity, String[] prgmNameList, int[] prgmImages) {
// TODO Auto-generated constructor stub
result=prgmNameList;
context=mainActivity;
imageId=prgmImages;
inflater = (LayoutInflater)context.
getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return result.length;
}
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return position;
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
public class Holder
{
TextView tv;
ImageView img;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
Holder holder=new Holder();
View rowView;
rowView = inflater.inflate(R.layout.new_custom_list, null);
holder.tv=(TextView) rowView.findViewById(R.id.textView1);
holder.img=(ImageView) rowView.findViewById(R.id.imageView1);
holder.tv.setText(result[position]);
holder.img.setImageResource(imageId[position]);
rowView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent myIntent = null;
if (position == 0) {
CustomAdapter.this.context.startActivity(new Intent(CustomAdapter.this.context, BalanceActivity.class));
}
if (position == 1) {
String url_1 = "http://www.facebook.com";
myIntent.putExtra("url", url_1);
CustomAdapter.this.context.startActivity(new Intent(CustomAdapter.this.context, WebShow1.class));
}
}
});
return rowView;
}
}
有downvoted [緊急乞](https://meta.stackoverflow.com/questions/326569/under-what-的情況下,可以-I加緊急 - 或其它相似的短語對我-任務)。請不要在將來的問題中以這種方式解決志願者問題,謝謝! – halfer
在這個問題上找不到緊急乞討......是否被刪除? – Opiatefuchs