簡體   English   中英

Android,滾動菜單內部具有多個視圖-XML視圖

[英]Android, Scroll Menu with multiple views inside - Views from XML

超級新手在這里。 在Google和這些論壇上搜索了4個小時,但看不到這個地址。 抱歉,是的,但是就像我說的,SUPER newb在這里。

我需要一個具有線性布局的滾動視圖。 在線性布局中,我需要自定義“迷你布局”。 這些是動態引入的。

這個想法是用戶登錄,然后我們返回一個包含其內容的數據流。 迷你版式將由圖片,上方和下方的文字以及一個按鈕組成。

我為此得到了一個xml,但是當我瀏覽數據列表時,它不會讓我多次附加該xml。 請幫助,如果我以最糟糕的方式這樣做,請告訴我。

謝謝。

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.springboard_view);

    // Set page title
    TextView temp = (TextView) findViewById(R.id.page_label);
    temp.setText("Springboard");

    // Get the message from the intent, format and set
    // We also need to keep the pdf's for the library page
    Intent intent = getIntent();
    String message = intent.getStringExtra(ffacademyActivity.EXTRA_MESSAGE);
    List<String[]> formattedStrings = formatStrings(message);
    List<String[]> pdfStrings = new ArrayList<String[]>();

    String[] almostThere;


    mInflater = (LayoutInflater) getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    LinearLayout convertView = (LinearLayout)mInflater.inflate(R.layout.sb_icon,null);



    while(!formattedStrings.isEmpty()) {
        setContentView(R.layout.sb_icon);
        almostThere = formattedStrings.remove(0);   

        if (almostThere[0].contains("product")) {
            TextView tempText = (TextView) findViewById(R.id.spring_board_title);
            tempText.setText(almostThere[2]);
            tempText = (TextView)findViewById(R.id.spring_board_description);
            tempText.setText(almostThere[5]);
        } else if (almostThere[0].contains("link")) {
            TextView tempText = (TextView) findViewById(R.id.spring_board_title);
            tempText.setText(almostThere[1]);
            tempText = (TextView)findViewById(R.id.spring_board_description);
            tempText.setText(almostThere[4]);
        } else {
            pdfStrings.add(almostThere);
        }

        setContentView(R.layout.springboard_view);
        LinearLayout linearLayout = (LinearLayout)findViewById(R.id.sbpad);
        linearLayout.addView(convertView);
    }



}

這不僅僅是帶有ArrayAdapter的普通ListView嗎? 類似於本示例中的一個: 自定義ListView項和適配器

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM