[技術討論] 求教! Android Database資料點show落一個ListView度

本帖最後由 sfcgta123 於 2015-2-5 23:19 編輯

是咁的,小弟比學校叫左去參加event,我個team既人java經驗唔多,但系過幾日就要交個mini game(詳情唔多講),宜家我組人就想系個SQLite database度裝D user既資料,然後比用戶系一開始個時以一個ListView既形式choose/add/delete user. 小弟左揾右揾,揾左點寫個database同個user interface,test 個時佢不停話"Your content must have a ListView whose id attribute is 'android.R.id.list'",完全無哂辦法...
1. Main program
public class SelectPlayer extends ListActivity {
    private database_man.PlayersDataSource Playersource;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.player_select);
        Button newbtn = (Button) findViewById(R.id.newplayer);
        Button delbtn = (Button) findViewById(R.id.delplayer);
        ListView PlayerList=(ListView) findViewById(R.id.PlayerList);
        Button backbtn = (Button) findViewById(R.id.back1);
.       ........
    }
}
我想個ListView出到Player name,Player Level(database已有),想請問可以點整? 假設個database系ABC,入面有playername,playerlevel,playermoney既object.

小弟知道自己表達得唔好,所以請大大有疑問既話,請指出! 要多D資料既話,小弟可以比到。希望各位大大指教,多謝!

5/2/2015更新: 小弟想問如果個ListView 入面有三個object,我想系user click 左一個object個時,佢會自動系database度load個user既profile(假設每個profile 有Name,Level,Money三個database field),咁可以點寫?

mini game? 過三關定食鬼?係咪一定要db?variable 得唔得?

TOP

回覆 2# 望月小妖


    我地要整一個車房game,玩簡單既整車。因為我既teammates預會有兩個或以上既profile, 所以要用db黎store user既data,貪db系個app close左之後都唔會lost左players' record.
    宜家我寫左一個介面會有一個TextView(畫面題目--Select the player),一個ListView(出player既名,等級,同埋佢有既錢),一個Select button,一個delete button 同一個back button,亦預備左一個DB黎儲玩家既記錄。

TOP

TOP

TOP

TOP

btw 你係咪用左咩LIBRARY 佢似係XML搵唔到個 view

TOP

回覆 6# kenny910


    呢個就可以代替到database?

TOP

這個是 extends ListActivity 的要求. See http://developer.android.com/ref ... p/ListActivity.html

Screen Layout
ListActivity has a default layout that consists of a single, full-screen list in the center of the screen. However, if you desire, you can customize the screen layout by setting your own view layout with setContentView() in onCreate(). To do this, your own view MUST contain a ListView object with the id "@android:id/list" (or list if it's in code)

TOP

回覆 9# Charcoal99


    多謝你! 我宜家嘗試緊extend 其他野黎解決呢個問題...

TOP