2012-03-06 3 views
0

전체 프로젝트를 ActivityGroups에서 단편을 사용하여 변환하려고합니다. 여기 작업 그룹을 조각으로 변환

내 예전의 코드입니다 :

SettingsActivityGroup

public class SettingsActivityGroup extends ActivityGroup 
{ 
// Keep this in a static variable to make it accessible for all the nested activities, lets them manipulate the view 
public static SettingsActivityGroup group; 

// Need to keep track of the history if you want the back-button to work properly, don't use this if your activities requires a lot of memory. 
private ArrayList<View> history; 

// Window focus changed listener 
public OnActivityGroupViewChanged activityGroupViewChangedListener = null; 

@Override 
protected void onCreate(Bundle savedInstanceState) 
{ 
    super.onCreate(savedInstanceState); 

    // Allocate history 
    this.history = new ArrayList<View>(); 

    // Set group 
    group = this;    

    // Start root (first) activity 
    Intent myIntent = new Intent(this, SettingsActivity.class); // Change to the first activity of your ActivityGroup 
    myIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 
    ReplaceView("SettingsActivity", myIntent); 
} 

SettingsActivity

public class SettingsActivity extends Activity 
{ 
String[] settingsLabels = {"Viderestilling", "Voicemail", "Vis nummer", 
      "Kø styring", "Optag samtaler", "Services" }; 
ListView lv; 

@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.settings); 
    lv = (ListView) findViewById(R.id.SettingsLV); 

    lv.setTextFilterEnabled(true); 

    populateListView(); 


} 

private void populateListView() 
{ 

     lv.setAdapter(new ArrayAdapter<String>(this, R.layout.settings_items, R.id.settings_item_label, settingsLabels)); 
     lv.setOnItemClickListener(new OnItemClickListener() { 
     public void onItemClick(AdapterView<?> parent, View view, 
      int position, long id) 
     { 
      // SwitchActivity(position); 
     } 
     }); 
} 

내가 대신 활동의 ListFragment를 확장 할 경우 - 나는 변경해야 할 사항은 무엇 모든 것이 여전히 작동하는지 확인하려면?

답변

0

Fragments에서 개발자 가이드 문서를 보았습니까? 필자는 정확한 사용 사례 (하나의 조각에있는 배열 기반 목록과 다른 조각에있는 세부 사항)를 거의 거의 설명한다고 생각합니다. APIDemos에서 전체 샘플 구현을 확인하십시오. API 4+ Support Demos에도 이전 버전과 호환되는 버전이 있습니다.