这里是我的Java:如何制作某个自定义的listview项目,发送给某个活动?
public class Cantos extends AppCompatActivity {
ListView lv;
Context context;
ArrayList cantoList;
public static String[] cantos = {"1: Abre Tu Oido", "2: A Cristo Quiero", "3: Acerquese Mi Clamor", "4: A Cristo Yo Alabare",
"5: Acude Dios", "6: Adelante", "7: A Dios Canto", "8: Adios Para Siempre", "9: Ahora Senor", "10: A Jesucristo Ven",
"11: Alabad A Dios"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_cantos);
initTypeface();
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(null);
toolbar.setNavigationIcon(getDrawable(R.drawable.abc_ic_ab_back_mtrl_am_alpha));
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(Cantos.this, MainMenu.class);
startActivity(i);
}
});
}
private void initTypeface() {
Typeface myTypeface = Typeface.createFromAsset(getAssets(), "fonts/AftaSerifThin-Regular.otf");
TextView text = (TextView) findViewById(R.id.toolbarCantos);
text.setTypeface(myTypeface);
}
}
这是我其他的Java与BaseAdapter(自定义的ListView):
public class CustomAdapter extends BaseAdapter {
String[] result;
Context context;
private static LayoutInflater inflater = null;
public CustomAdapter(Cantos cantos, String[] cantos1) {
result = cantos1;
context = cantos;
inflater = (LayoutInflater)context.
getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
public int getCount() {
return result.length;
}
@Override
public Object getItem(int position) {
return position;
}
@Override
public long getItemId(int position) {
return position;
}
public class Holder
{
TextView tv;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
Holder holder = new Holder();
View rowView;
rowView = inflater.inflate(R.layout.cantos_list, null);
holder.tv = (TextView) rowView.findViewById(R.id.textCanto);
holder.tv.setText(result[position]);
Typeface myFont = Typeface.createFromAsset(context.getAssets(), "fonts/AftaSerifThin-Regular.otf");
holder.tv.setTypeface(myFont);
return rowView;
}
}
我怎样才能让一个特定的项目送我到另一一定的活动? 提前谢谢! 对不起,如果我垃圾邮件太多!我几乎完成了一些基础知识!我求求你应付我!
需要更多信息。什么项目会导致新的活动?你的listview在哪里声明。适配器在哪里使用? – Samnon
项目“1 Abre Tu Oido”和哎呀!对不起,我删除了意外的代码。这里是'context = this; lv =(ListView)findViewById(R.id.ListView); lv.setAdapter(new CustomAdapter(this,cantos));' – Alex