Edited at

ActionBar-PullToRefresh使ってみたメモ

More than 5 years have passed since last update.

ListView使いたかったのサンプルコード拝借してきて、こんなかんじのかけば多分動くんじゃね程度のメモコード


メモコード


public class MainActivity extends Activity {

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

SampleListFragment sampleFragment = new SampleListFragment();
if (sampleFragment != null) {
getFragmentManager().beginTransaction()
.replace(android.R.id.content, sampleFragment).commit();
}
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {

getMenuInflater().inflate(R.menu.main, menu);
return true;
}

}

public class SampleListFragment extends ListFragment implements OnRefreshListener {

private PullToRefreshLayout mPullToRefreshLayout;

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view,savedInstanceState);
ViewGroup viewGroup = (ViewGroup) view;

mPullToRefreshLayout = new PullToRefreshLayout(viewGroup.getContext());

ActionBarPullToRefresh.from(getActivity())
.insertLayoutInto(viewGroup)
.theseChildrenArePullable(android.R.id.list, android.R.id.empty)
.listener(this)
.setup(mPullToRefreshLayout);

}

@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);

}

@Override
public void onRefreshStarted(View view) {
// do some stuff...
mPullToRefreshLayout.setRefreshComplete();
}
}


ActionBar-PullToRefresh


このへんのサンプル見ると他のviewでの実装もわかりやすくてよいかも


This is a Preview

っていうてるのでAPIはまだこれから変わる可能性あるのでちょと気をつけないと