我的代码:
ListView lv=getListView();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
new ProgressTask(MainActivity.this).execute();
ImageView image = (ImageView)findViewById(R.id.image);
!!! lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
intent = new Intent(MainActivity.this,DetailInfo.class);
intent.putExtra("title",jsonlist.get(position).get("title"));
intent.putExtra("description",jsonlist.get(position).get("description"));
intent.putExtra("description",jsonlist.get(position).get("description"));
intent.putExtra("url",jsonlist.get(position).get("image"));
startActivity(intent);
问题是我试着将OnItemClickListener设置为lv.How我可以初始化lv吗?我有Activity扩展ListActivity.I无法找到id的id,因为ListView有id = android:id / list。我有适配器,使用setListAdapter(适配器)和all.How我可以为lv设置监听器吗?
答案 0 :(得分:0)
首先在onCreate()中初始化你的lv,并在下面执行,
def issorted(numlist):
previous = numlist[0]
for value in numlist:
if value < previous:
# the current value is smaller than the previous,
# so the list is not (forward) sorted. Exit with False
return False
previous = value
# all values were equal or larger than their predecessors, so
# the list is sorted, exit with True
return True