2
回答
我的ListView怎么写让每个Item点击事件是跳到不同的Activity
利用AWS快速构建适用于生产的无服务器应用程序,免费试用12个月>>>   
package wolf.test;

import java.util.ArrayList;
import java.util.HashMap;

import wolf.love_1.Love_1_1;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.SimpleAdapter;

public class Love extends Activity {

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.love);
ListView list = (ListView)findViewById(R.id.lovelist);
ArrayList<HashMap<String,String>> listItem = new ArrayList<HashMap<String,String>>();
HashMap<String,String> m1= new HashMap<String,String>();
HashMap<String,String> m2= new HashMap<String,String>();
HashMap<String,String> m3= new HashMap<String,String>();
m1.put("text", "1.你是何种恋爱控?");
m2.put("text", "2.你必修啥爱情骗规则?");
m3.put("text", "3.你和他是毕分族吗?");
listItem.add(m1);
listItem.add(m2);
listItem.add(m3);
SimpleAdapter ListAdapter = new SimpleAdapter(this, listItem, R.layout.user, new String[]{"text"}, new int[]{R.id.text});
list.setAdapter(ListAdapter);
list.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,long arg3) {

}
});
}
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}

}

举报
张铮
发帖于5年前 2回/3K+阅
顶部