我想将构造函数中的字符串转换为双精度,我无法在构造函数中更改它,因为在一个进程中,变量必须是双精度,而其他类必须是字符串,你能告诉我如何转换它.. ? 这是我的构造函数:
public class DataItem {
String ijiInvest, ijiId;
String tanggal;
double persenHmint1,inuNilai selisih,persen_hke1;
public DataItem(String ijiInvest, double persenHmint1, Double inuNilai,
double selisih,double persen_hke1, String tanggal,String ijiId) {
// TODO Auto-generated constructor stub
this.ijiInvest = ijiInvest;
this.persenHmint1 = persenHmint1;
this.inuNilai = inuNilai;
this.selisih = selisih;
this.ijiId = ijiId;
this.tanggal = tanggal;
this.persen_hke1=persen_hke1;
}
public String getIjiInvest() {
return ijiInvest;
}
public String getIjiId() {
return ijiId;
}
public String getTanggal() {
return tanggal;
}
public double getPersenHmint1() {
return persenHmint1;
}
public Double getInuNilai() {
return inuNilai;
}
public double getSelisih() {
return selisih;
}
public double persen_hke1(){
return persen_hke1;
}
在我的基本适配器中,我想将 getInuNilai() 更改为字符串,这是我的基本适配器:
public class TabelAdapter extends BaseAdapter{
Context context;
ArrayList<DataItem> listData;//stack
int count;
public TabelAdapter(Context context, ArrayList<DataItem>listData){
this.context=context;
this.listData=listData;
this.count=listData.size();
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return count;
}
@Override
public Object getItem(int arg0) {
// TODO Auto-generated method stub
return null;
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return 0;
}
@Override
public View getView(int position, View v, ViewGroup parent) {
// TODO Auto-generated method stub
View view= v;
ViewHolder holder= null;
if(view==null){
LayoutInflater inflater=(LayoutInflater)context.getSystemService(context.LAYOUT_INFLATER_SERVICE);
view= inflater.inflate(R.layout.main, null);
holder=new ViewHolder();
holder.nama=(TextView)view.findViewById(R.id.name);
holder.email=(TextView)view.findViewById(R.id.email);
view.setTag(holder);
}
else{
holder=(ViewHolder)view.getTag();
}
holder.nama.setText(listData.get(position).getTanggal());
// holder.email.setText(listData.get(position).getInuNilai());
return view;
}
static class ViewHolder{
TextView nama, email;
}
我不能 setText getInuNilai() 因为它返回为双精度,你能告诉我如何转换它吗?