LoginSignup
2
2

More than 5 years have passed since last update.

ActionBar-PullToRefresh使ってみたメモ

Last updated at Posted at 2013-11-18

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はまだこれから変わる可能性あるのでちょと気をつけないと

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2