Android Open Source - 50AndroidHacks Adapter Activity






From Project

Back to project page 50AndroidHacks.

License

The source code is released under:

Apache License

If you think the Android project 50AndroidHacks listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.github.yftx.AndroidHacks.sectionAdapter;
/*from  ww w .  jav a  2 s . c o m*/
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.AbsListView;
import android.widget.ListView;
import android.widget.TextView;
import com.github.yftx.AndroidHacks.R;

/**
 * User: Liuzl
 * Date: 13-11-28
 *
 * pinned section listview ???????????????
 * https://github.com/beworker/pinned-section-listview.git
 *
 */
public class AdapterActivity extends Activity {
    private ListView mListView;
    private TextView header;
    private int topVisiblePosition = -1;
    private SampleAdapter mAdapter;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.adapter_activity);
        header = (TextView) findViewById(R.id.header);
        header.setVisibility(View.GONE);
        mListView = (ListView) findViewById(R.id.list);
        mListView.setEmptyView(findViewById(R.id.empty));
        mListView.setOnScrollListener(new AbsListView.OnScrollListener() {
            @Override
            public void onScrollStateChanged(AbsListView view, int scrollState) {
            }

            @Override
            public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
                if (firstVisibleItem != topVisiblePosition) {
                    topVisiblePosition = firstVisibleItem;
                    refreshToppHeader(topVisiblePosition);
                }
            }

            private void refreshToppHeader(int topVisiblePosition) {
                if (mAdapter == null) return;
                final String text = mAdapter.getItem(topVisiblePosition);
                header.setText(text.substring(0,1));
            }
        });
    }

    public void onClickShowContent(View view) {
        mAdapter = new SampleAdapter(getLayoutInflater());
        mListView.setAdapter(mAdapter);
        header.setVisibility(View.VISIBLE);
    }
}




Java Source Code List

com.github.yftx.AndroidHacks.MainActivity.java
com.github.yftx.AndroidHacks.sectionAdapter.AdapterActivity.java
com.github.yftx.AndroidHacks.sectionAdapter.SampleAdapter.java
com.github.yftx.AndroidHacks.sectionAnimation.KenBurnsEffect.java
com.github.yftx.AndroidHacks.sectionAnimation.TextAndImageAnimation.java
com.github.yftx.AndroidHacks.sectionLayout.CanvasActivity.java
com.github.yftx.AndroidHacks.sectionLayout.WeightActivity.java
com.github.yftx.AndroidHacks.sectionLayout.customview.Cascade.java
com.github.yftx.AndroidHacks.sectionLayout.customview.CustomCard.java
com.github.yftx.AndroidHacks.sectionPatterns.broadcast.BroadcastReceiverActivity.java
com.github.yftx.AndroidHacks.sectionPatterns.broadcast.MyService.java
com.github.yftx.AndroidHacks.sectionPatterns.mvp.model.IOpenStatus.java
com.github.yftx.AndroidHacks.sectionPatterns.mvp.model.impl.OpenStatus.java
com.github.yftx.AndroidHacks.sectionPatterns.mvp.presenter.SplashPresenter.java
com.github.yftx.AndroidHacks.sectionPatterns.mvp.view.ISplashView.java
com.github.yftx.AndroidHacks.sectionPatterns.mvp.view.impl.SplashActivity.java
com.github.yftx.AndroidHacks.sectionTipsAndTricks.FormatTextView.java
com.github.yftx.AndroidHacks.sectionTipsAndTricks.GlowTextView.java
com.github.yftx.AndroidHacks.sectionTipsAndTricks.LEDTextView.java
com.github.yftx.AndroidHacks.sectionTipsAndTricks.NoBgPhoneWindow.java
com.github.yftx.AndroidHacks.sectionTipsAndTricks.ScreenOrientation.java
com.github.yftx.AndroidHacks.sectionTipsAndTricks.TestFragmentAdapter.java
com.github.yftx.AndroidHacks.sectionTipsAndTricks.TestFragment.java
com.github.yftx.AndroidHacks.sectionTipsAndTricks.ToastPostion.java