1. 첫번째 질문입니다 위에서 일단 ListActivity로 뿌려주고 있습니다(LIstView사용)
그리고 그밑에 Total은 따로 TextView로 뿌려주고 있구요
String[] from = new String[] {"JUYUDATE" , "LITER" , "MONEY"};
int[] to = new int[] { R.id.juyu_list_DATE
, R.id.juyu_list_LITER
, R.id.juyu_list_MONEY};
SimpleCursorAdapter juyu_list = new SimpleCursorAdapter(this,
R.layout.juyu_list, cursor, from, to);
//가져온 커서의 내용에서 가격을 전부 가져와 합하여 준다
for(int i=0 ; i<juyu_list.getCursor().getCount() ;i++){
totalValue+=(int)cursor.getInt(4);
cursor.moveToNext();
}
//가격의 총합을 넘버포멧으로 변경하여 세자리마다 ' , '를 찍어준다
NumberFormat nf = NumberFormat.getInstance();
String strTotalValue = nf.format(totalValue);
//출력한다(Total)
total.setText(strTotalValue+"");
//커서로 불러온 리스트를 출력한다
setListAdapter(juyu_list);//여기서 뿌려준것은 가격이 Integer로 DB에 들어가 있습니다
머 이런식인데
Total처럼
위에서 리스트로 뿌려주는것을
9000 => 9,000 이런식으로 뿌여주고 싶은데
어떻게 커서로 불러온것을 수정해야할지모르겠네요
저방식으로는 수정이 불가능한지요??
아니면 DB에서 불러와서 뿌려주는 방식이 저방식말고
다른것으로 해야하는지요 또 그것은 어떤것이 있는지 알고 싶습니다
=======================================================================================

마찬가지로 위에것도 저방식으로 뿌려 주려했는데
"에어클리너 필터" 이것은 마찬가지로 DB에 들어가 있는것이라
뿌려주는것은 쉬운데
그리고 그밑에 주기 : 2000km <==이것도 DB에 들어있습니다 어차피 위에처럼
--------------------------------------------------------------------------------
-에어클리너 필터 주기 : 2000km / 200km 초과 -
--------------------------------------------------------------------------------
이런식으로 뿌려주면되니 괜찮은데 "200km초과 "이것이 문제입니다
저것은 다른변수에 int a=10000 이들어있으면
에어클리너필터가 들어있는 SQLITE table 에 column으로
현재 km수가 들어있습니다
예를들면 13000이라고 들어있으면 13000-10000 =3000이나오고
그값을 3000-2000(주기) =1000
1000km초과 이런식으로 뿌려주어야하는데 가능한지요
*가장큰 질문요지는 제가 찾아본 바로는 제가 했던방식으로 뿌려주면 수정 및 가공을 못하는것 같습니다
화면에도 리스트처럼 뿌려주고 제가 그값을 수정 및 가공하여 뿌려줄수있는 방법이 있나요??
질문이 길어져서 죄송합니다 아시는분은 답글좀 달아주셨으면 좋겠습니다
현재 안드로이드 개발중인데 갑자기 막히네요 ㅜㅜ 며칠째 고민중입니다
공지사항을 다 읽었음
꼬마네꼬님 자세한 설명 다시 한번 부탁 드리겠습니다
잘안되네요..
현상태는
날짜 주유량 가격
9,000 9,000L 9,000원
10,000 10,000L 10,000원
이런식으로 나오는데 TextView 설정을 따로 안해주 었었습니다
package com.sm4;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import android.app.ListActivity;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.SimpleCursorAdapter.ViewBinder;
public class JUYU extends ListActivity {
Context c=this;
TextView mDateDisplay;
TextView selectedCar;
TextView total;
int totalValue=0;
private static final int ACTIVITY_CREATE=0;
private static final int ACTIVITY_EDIT=1;
private DbAdapter mDbHelper;
private int mYear;
private int mDay;
private int mMonth;
private Cursor cursor;
DbMemory dbMemory = DbMemory.getInstance();
MYCAR_interface mif = MYCAR_interface.getInstance();
JUYU_interface jif = JUYU_interface.getInstance();
ArrayAdapter<String> adapter;
private String[] carName;
private int idCount;
private Spinner spinner;
private final Calendar calendar = Calendar.getInstance();
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.juyu);
selectedCar= (TextView)findViewById(R.id.selectedCar);
mDateDisplay = (TextView)findViewById(R.id.date_Display);
total = (TextView)findViewById(R.id.total_juyu_list_text);
mDbHelper = new DbAdapter(this);//Context 넣어줌
fillData();
//current date를 가져온다
mYear = calendar.get(Calendar.YEAR);
mMonth = (calendar.get(Calendar.MONTH));
mDay = calendar.get(Calendar.DAY_OF_MONTH);
fillList();
//버튼
Button insert_bt = (Button) findViewById(R.id.btn_addJUYU);
Button selelct_bt = (Button) findViewById(R.id.btn_selectMyCar);
Button forwardDate_bt = (Button) findViewById(R.id.btn_forwardDate);
Button backDate_bt = (Button) findViewById(R.id.btn_backDate);
//버튼 클릭시 처리
insert_bt.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
addJUYU();
}
});
forwardDate_bt.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
fowardDisplay();
totalValue=0;
fillList();
}
});
backDate_bt.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
nextDisplay();
totalValue=0;
fillList();
}
});
selelct_bt.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent i = new Intent(c, JUYU_select_view.class);
startActivity(i);
}
});
currentDisplay();
}//End of onCreate()
private void fillData() {
try{
mDbHelper.open();
if(mif.isfetchCar(DbAdapter.mDb)){
cursor = mif.fetchCar(DbAdapter.mDb);
}
}catch(Exception e){
e.printStackTrace();
}finally{
mDbHelper.close();
}
selectedCar.setText(cursor.getString(3));
startManagingCursor(cursor);
String[] from = new String[] {"TITLE"};
int[] to = new int[] { R.id.result_car_name };
// Now create an array adapter and set it to display using our row
SimpleCursorAdapter cars = new SimpleCursorAdapter(this,
R.layout.juyu_row, cursor, from, to);
setListAdapter(cars);
}//End of fillData()
private void fillList() {
try{
mDbHelper.open();
if(jif.isfetchList(DbAdapter.mDb)){
cursor = jif.fetchJuyuList(DbAdapter.mDb
, dbMemory.myCarTbl
, dbMemory.dateYear
, dbMemory.dateMonth
);
}
}catch(Exception e){
e.printStackTrace();
}finally{
mDbHelper.close();
}
startManagingCursor(cursor);
String[] from = new String[] {"JUYUDATE" , "LITER" , "MONEY"};
int[] to = new int[] { R.id.juyu_list_DATE
, R.id.juyu_list_LITER
, R.id.juyu_list_MONEY};
// Now create an array adapter and set it to display using our row
// SimpleCursorAdapter juyu_list = new SimpleCursorAdapter(this,
// R.layout.juyu_list, cursor, from, to);
SmsCursorAdapter adapter = new SmsCursorAdapter(this, R.layout.juyu_list, cursor, from, to);
for(int i=0 ; i<adapter.getCursor().getCount() ;i++){
totalValue+=(int)cursor.getInt(4);
cursor.moveToNext();
}
NumberFormat nf = NumberFormat.getInstance();
String strTotalValue = nf.format(totalValue);
total.setText(strTotalValue+"");
System.out.println("totalValue : "+strTotalValue);
setListAdapter(adapter);
// total.setText(totalValue);
}//End of fillData()
public void setMyCarName(Cursor cu) {
cu.moveToFirst();
idCount = cu.getCount();
carName = new String[idCount];//cu.getCount()는 3 이라고 나옵니다
//
for (int i = 0; i < idCount ; i++) {
carName[i]=cursor.getString(3);
System.out.println("carName[" + i + "] : "+ carName[i]);
cu.moveToNext();
}
}//End of saveMemory()
private void fowardDisplay() {
calendar.add(Calendar.MONTH, -1);
mYear = calendar.get(Calendar.YEAR);
mMonth = calendar.get(Calendar.MONTH);
mDateDisplay.setText(
new StringBuilder().append(mYear).append("년").append(mMonth + 1).append("월")
);
dbMemory.dateYear=mYear;
dbMemory.dateMonth=mMonth+1;
dbMemory.dateDay=mDay;
}
private void nextDisplay() {
calendar.add(Calendar.MONTH, +1);
mYear = calendar.get(Calendar.YEAR);
mMonth = calendar.get(Calendar.MONTH);
mDateDisplay.setText(
new StringBuilder().append(mYear).append("년").append(mMonth + 1).append("월")
);
dbMemory.dateYear=mYear;
dbMemory.dateMonth=mMonth+1;
dbMemory.dateDay=mDay;
}
private void currentDisplay(){
mYear = calendar.get(Calendar.YEAR);
mMonth = calendar.get(Calendar.MONTH);
mDateDisplay.setText(
new StringBuilder().append(mYear).append("년").append(mMonth + 1).append("월")
);
dbMemory.dateYear=mYear;
dbMemory.dateMonth=mMonth;
dbMemory.dateDay=mDay;
}
private void addJUYU() {
Intent i = new Intent(this, JUYU_add_view.class);
// 수행후 onActivityResult호출됨.
startActivityForResult(i, ACTIVITY_CREATE);
}//End of createMycar()
/**
* List항목을 선택시
*/
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
try{
mDbHelper.open();
Cursor c = cursor;
c.moveToPosition(position);
System.out.println("onListItemClick_id : "+id);
Intent i = new Intent(this, JUYU_edit_view.class);
i.putExtra("_id", id);
i.putExtra("idMYCAR_TBL", c.getInt(1));
i.putExtra("JUYUTYPE", c.getString(2));
i.putExtra("JUYUDATE", c.getString(3));
i.putExtra("MONEY", c.getInt(4));
i.putExtra("LITER", c.getFloat(5));
i.putExtra("DISTANCE", c.getFloat(6));
startActivityForResult(i, ACTIVITY_EDIT);
}catch(Exception e){
e.printStackTrace();
}finally{
mDbHelper.close();
}
}
/**
* DbAdapter로 입력된 param들을 보낸다
*/
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
if(intent == null){//Ex.핸드폰의 뒤로 가기 클릭
return;
}
Bundle extras = intent.getExtras();
switch(requestCode) {
case ACTIVITY_CREATE:
fillData();
break;
case ACTIVITY_EDIT:
Long mRowId = extras.getLong("_id");
if (mRowId != null) {
}
break;
}
// fillData();
}//End of onActivityResult()
public class SmsCursorAdapter extends SimpleCursorAdapter {
public SmsCursorAdapter(Context context
, int layout
, Cursor c
, String[] from
, int[] to) {
super(context, layout, c, from, to);
this.setViewBinder(new SmsViewBinder());
}
}
public class SmsViewBinder implements ViewBinder {
private static final String TAG = "SmsViewBinder";
public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
// Log.d(TAG, "view:" + ((TextView)view).getId() + "/R.id.time:" + R.id.time + "/columnIndex:" + columnIndex );
if(view instanceof TextView) {
long amount = cursor.getInt(4);
NumberFormat nfs = NumberFormat.getInstance();
String strValue = nfs.format(amount);
((TextView)view).setText(strValue);
return true;
}
return false;
}
}
}



