JWorld@TW the best professional Java site in Taiwan
      註冊 | 登入 | 全文檢索 | 排行榜  

» JWorld@TW » Java ME、Google Android 平台與 JavaCard 討論區 » Android  

按列印兼容模式列印這個話題 列印話題    把這個話題寄給朋友 寄給朋友    訂閱主題
reply to topicthreaded modego to previous topicgo to next topic
本主題所含的標籤
作者 我想將二個cursor出來的東西放在同一個list裡
mayday21





發文: 9
積分: 0
於 2011-07-27 13:36 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import java.util.Calendar;
 
import android.app.Activity;
import android.app.ListActivity;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.Color;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
import android.widget.TextView;
 
public class list1 extends ListActivity {
  private TextView mDateDisplay;
  //private ScrollView mScrollView;
   
  private int year;
  private int month;
  private int day;
  private String s;
  private String type1;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.setContentView(R.layout.main);
        
        mDateDisplay = (TextView) findViewById(R.id.textView1);
        final Calendar c = Calendar.getInstance();
        year = c.get(Calendar.YEAR);
        month = c.get(Calendar.MONTH);
        day = c.get(Calendar.DAY_OF_MONTH);
        mDateDisplay.setTextColor(Color.rgb(0, 0, 0));
        updateDisplay();
        
        s=year+"/"+(month+1)+"/"+day;
                  
          DB helper= new DB(this);
      Cursor get = helper.get(s);
      startManagingCursor(get);
      
         Cursor getin=helper.getin(s);
       startManagingCursor(getin);
          
      int i = 0;
               if(get.getCount()>=0)
               {
                  
                 SimpleCursorAdapter adapter =
                        new SimpleCursorAdapter(this, R.layout.list_item, get, new String[] { "spitem_name","spmoney"},
                            new int[] { R.id.te1,R.id.te2});
                 this.setListAdapter(adapter);        
             i=i+1;  
               get.moveToPosition(i);
               
               }
               //Toast.makeText( first.class, type1, Toast.LENGTH_SHORT).show();
              
               
        
              int j=0;
               if (getin.getCount()>=0)
               {
                 SimpleCursorAdapter adapter1 =
                       new SimpleCursorAdapter(this, R.layout.list_item, getin, new String[] { "item_name","inmoney"},
                            new int[] { R.id.te1,R.id.te2});
             this.setListAdapter(adapter1);
             
              j=j+1;
              getin.moveToPosition(j);
                 
               }
 
       helper.close();
      }
    
    //顯示時間  
      private void updateDisplay() 
      {
          mDateDisplay.setText(new StringBuilder()
          .append(month + 1).append("-").append(day).append("-").append(
          year).append(" "));
      }
}

想將二個cursor出來的東西放在同一個SimpleCursorAdapte
但原本這樣寫 後面的cursor會直接把前面的蓋掉
不知道有沒有辦法能讓二個都顯示出來

如果這個方法不行有沒有什麼其他的方法可以做到...
謝謝..


reply to postreply to post
作者 Re:我想將二個cursor出來的東西放在同一個list裡 [Re:mayday21]
koji

秒速5センチメートル

站長

發文: 8415
積分: 19
於 2011-07-27 19:18 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
你應該先把資料合併以後
在產生 SimpleCursorAdapter

koji


reply to postreply to post
JCConf Taiwan 2015 開始售票了!!
Facebook上的TWJUG社團,歡迎加入
作者 Re:我想將二個cursor出來的東西放在同一個list裡 [Re:koji]
mayday21





發文: 9
積分: 0
於 2011-07-28 00:42 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
謝謝大大回答

資料合併?
存進陣列裡嗎?


mayday21 edited on 2011-07-28 17:30
reply to postreply to post
作者 Re:我想將二個cursor出來的東西放在同一個list裡 [Re:mayday21]
luo673





發文: 171
積分: 0
於 2011-07-28 09:41 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
:::你可以在SQL語法裡用Inner Join將兩個資料表的內容合併起來!!!

reply to postreply to post
作者 Re:我想將二個cursor出來的東西放在同一個list裡 [Re:luo673]
mayday21





發文: 9
積分: 0
於 2011-07-28 17:33 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
謝謝大大的回答

但我的二個資料表好像沒共通的欄位...


mayday21 edited on 2011-07-28 21:27
reply to postreply to post
» JWorld@TW »  Java ME、Google Android 平台與 JavaCard 討論區 » Android

reply to topicthreaded modego to previous topicgo to next topic
  已讀文章
  新的文章
  被刪除的文章
Jump to the top of page

JWorld@TW 本站商標資訊

Powered by Powerful JuteForum® Version Jute 1.5.8