我想在我的項目中使用https://github.com/JakeWharton/Android-ViewPagerIndicator插件實現片段。Android片段執行
我的片段
public final class NearByFragment extends Fragment {
private static String TAG = "bMobile";
public static NearByFragment newInstance(String content) {
NearByFragment fragment = new NearByFragment();
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
Log.d(TAG, "onCreate");
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
Log.d(TAG, "onCreateView");
return inflater.inflate(R.layout.fragment_search_nearby, null);
}
}
現在我想執行一些代碼就像開始啓動一個新線程,並從服務器下載一個JSON,然後分配從我下載內容的列表視圖。在片段中,我們在onCreateView中分配視圖。所以我應該在哪裏寫
listview = (ListView) findViewById(R.id.list_items);
((TextView) findViewById(R.id.title_text))
.setText(R.string.description_blocked);
和其他代碼來生成片段視圖?