I would like to have some possibility in my app.
(我想在我的应用中有一些可能性。)
I'd like to open browser by link which will be get from json response when user will click on some item in ListView. (我想通过链接打开浏览器,当用户单击ListView中的某些项时,该链接将从json响应中获取。)
I've already did some work, and I have some links when user tap on some item, but I can't make it work, to open the browser. (我已经做了一些工作,当用户点击某些项目时我有一些链接,但是我无法使其正常工作以打开浏览器。)
How I may do it? (我该怎么做?)
MainActivity
(主要活动)
ArrayList<Earthquake> earthquakes = QueryUtils.extractEarthquakes();
ListView listView = (ListView) findViewById(R.id.list);
EarthquakeAdapter adapter = new EarthquakeAdapter(this, earthquakes);
listView.setAdapter(adapter);
Adapter class
(转接器类别)
public EarthquakeAdapter(Context context, List<Earthquake> list ) {
super(context, 0, list);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View listView = convertView;
if (listView == null) {
listView = LayoutInflater.from(getContext()).inflate(R.layout.list_items, parent,
false);
}
...
listView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(getContext(),pojo.getUrl(),Toast.LENGTH_SHORT).show();
}
});
return listView;
}
ask by Aws translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…