2013-11-23 23 views
3

我已經嘗試了一段時間在Eclipse中創建Android應用程序。而我用了「BlankActivity」模板與「導航類型:刷卡次數+標題條」選項...如何在eclipse中的android應用程序模板中編輯內容?

我可以更改選項卡的名稱編輯文件「\水庫\值\ strings.xml中」 ......

<string name="title_section1">Section 1</string> 
<string name="title_section2">Section 2</string> 
<string name="title_section3">Section 3</string> 

但我不知道如何添加更多標籤/節(不只是添加下面這些另一行,因爲我認爲),無論是如何編輯部分的內容(我查看項目中的每個文件,並且找不到應該在哪裏編輯)... D:

感謝您幫助我...

+0

你試過研究這個嗎?在發佈問題之前,你應該這樣做。 –

+0

爲了記錄,您「更改標籤名稱」只是更改標籤名稱所引用的** String's **名稱。所以String名稱爲title_section1,你正在改變該String名稱。那麼選項卡名稱被設置爲無論title_section1是什麼,所以這就是如何工作。添加更多的字符串只是添加更多的字符串。就這麼簡單。它不會爲您創建佈局。 –

+0

@mikeyaworski我試過了,但是在任何地方找不到答案......:/ – user3023946

回答

0

你應該通過編輯添加新的選項卡預先生成

public Fragment getItem(int position) { 
      // getItem is called to instantiate the fragment for the given page. 
      // Return a DummySectionFragment (defined as a static inner class 
      // below) with the page number as its lone argument. 
      Fragment fragment = new DummySectionFragment(); 
      Bundle args = new Bundle(); 
      args.putInt(DummySectionFragment.ARG_SECTION_NUMBER, position + 1); 
      fragment.setArguments(args); 
      return fragment; 
     } 

DummyScetionFragment其實你想通過選擇特定的標籤,查看片段,所以你應該定義自己的片段(與他們各自的佈局文件在XML)根據這個預生成的例子:

public static class DummySectionFragment extends Fragment { 
     /** 
     * The fragment argument representing the section number for this 
     * fragment. 
     */ 
     public static final String ARG_SECTION_NUMBER = "section_number"; 

     public DummySectionFragment() { 
     } 

     @Override 
     public View onCreateView(LayoutInflater inflater, ViewGroup container, 
       Bundle savedInstanceState) { 
      View rootView = inflater.inflate(R.layout.fragment_main_dummy, 
        container, false); 
      TextView dummyTextView = (TextView) rootView 
        .findViewById(R.id.section_label); 
      dummyTextView.setText(Integer.toString(getArguments().getInt(
        ARG_SECTION_NUMBER))); 
      return rootView; 
     } 
    } 
相關問題