我是Android应用程序开发的新手。我目前正在研究一个项目,该项目处理我的android项目中只包含一列和多行的csv文件的导入。我能够使用csv适配器和数组适配器将这些csv文件读入我的项目,并且我没有使用任何字符串数组。仅使用csvadapter和数组适配器。现在在列表视图中显示所有csv数据,我有一个问题,当点击列表中的项目时,我想要为项目名称烘烤。我尝试了所有可能的组合,但它只显示了一个吐司字串@ somerandomvalue。请求有人帮助我。提前致谢。
The following is my csvadapter class. The .csv files are in placed in assets folder..
public class CSVAdapter extends ArrayAdapter<clock>{
Context ctx;
public CSVAdapter(Context context,int textViewResourceId)
{
super (context,textViewResourceId);
this.ctx = context;
loadArrayFromFile();
}
@Override
public View getView(final int pos,View convertView,final ViewGroup parent){
TextView mView=(TextView)convertView;
if(null == mView){
mView = new TextView(parent.getContext());
mView.setTextSize(28);
}
mView.setText(getItem(pos).getTime());
return mView;
}
这是我的课程,将.csv数组读入GUI
public class mrvtoparanur extends Activity {
CSVAdapter mAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mrvtoparanur);
final ListView mList = (ListView)findViewById(R.id.mrvtoparanurlist);
mAdapter=new CSVAdapter(this,-1);
mList.setAdapter(mAdapter);
mList.setOnItemClickListener(new OnItemClickListener()
{
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
Toast.makeText(getApplicationContext(), "you selected item number"+arg2, Toast.LENGTH_SHORT).show();
}});
}