2013-04-22 1 views
1

ID 속성 'android.R.id.list'내용은 id가 속성 'android.R.id.list'이다 ListView가 있어야합니다

I이다 ListView가 있어야합니다 귀하의 콘텐츠를 전에 내가 다룬이 오류가 생겼어. 여러 가지 ID를 시도했지만 너무 도움이되지 않습니다. 아래에서 볼 수 있듯이 이름이 정확하다고 보입니다. 나는 그것이 내가 조각과 listfragments 등에 새로운 사실과 관련이 있다고 생각한다. 코드의 관련 비트를 게시했습니다. 더 많은 코드가 필요한 경우이를 제공 할 것입니다.

아이디어가 있으십니까?

public class DisplayInfo extends FragmentActivity { 


SectionsPagerAdapter mSectionsPagerAdapter; 

/** 
* The {@link ViewPager} that will host the section contents. 
*/ 
ViewPager mViewPager; 


@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_display_info); 

    mSectionsPagerAdapter = new SectionsPagerAdapter(
      getSupportFragmentManager()); 

    new CreateTimetablesTask().execute(); 
    Log.d("task done", "task"); 
    // Set up the ViewPager with the sections adapter. 
    mViewPager = (ViewPager) findViewById(R.id.pager); 
    mViewPager.setAdapter(mSectionsPagerAdapter); 

} 

}

public class DummySectionFragment extends ListFragment { 
private Integer arrayListId; 
ViewGroup myViewGroup; 
public static final String CATEGORY_POSITION = "section_number"; 
public static DummySectionFragment newInstance(int pos) { 
    DummySectionFragment f = new DummySectionFragment(); 

    // Supply num input as an argument. 
    Bundle args = new Bundle(); 
    args.putInt(CATEGORY_POSITION, pos); 
    f.setArguments(args); 

    return f; 
} 

@Override 
public void onCreate(Bundle savedInstanceState) { 
    //get the id for your array list 
    super.onCreate(savedInstanceState); 
    arrayListId = getArguments() != null ? getArguments().getInt(CATEGORY_POSITION) - 1 : 1; 
} 

//create the list view layout 
@Override 
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 
    myViewGroup = container; 
    View v = inflater.inflate(R.layout.list_row, container, false); 
    return v; 
} 

@Override 
public void onActivityCreated(Bundle savedInstanceState) { 
    super.onActivityCreated(savedInstanceState); 
    ArrayAdapter<SingleClass> arrayAdapter =  
new ArrayAdapter<SingleClass>(getActivity(), R.layout.fragment_display_info, android.R.id.list); 

    setListAdapter(arrayAdapter); 
} 

} 

fragment_display_info.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:orientation="vertical" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

<ListView 
    android:id="@android:id/list" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"> 
</ListView> 

</LinearLayout> 

activity_display_info.xml

<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/pager" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context=".DisplayOnlineTimetable" > 

<!-- 
This title strip will display the currently visible page title, as well as the page 
titles for adjacent pages. 
--> 

<android.support.v4.view.PagerTitleStrip 
    android:id="@+id/pager_title_strip" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_gravity="top" 
    android:background="#33b5e5" 
    android:paddingBottom="4dp" 
    android:paddingTop="4dp" 
    android:textColor="#fff" /> 

+0

'ListFragment'를 확장 하시겠습니까? – midhunhk

답변

3
@Override 
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 
    myViewGroup = container; 
    View v = inflater.inflate(R.layout.fragment_display_info, container, false); 
    return v; 
} 

ListFragmentonCreateView 방법 내에 잘못된 레이아웃을 제공하고 있습니다.

+0

좋은 잡기. ;-) –

+0

오신 것을 환영합니다 .... – Triode

+0

고마워, 네가 맞아. 코드의 해당 부분에 대해서도주의를 기울이지 않았습니다. – user2236580

관련 문제