編輯:關於Android編程
import android.annotation.SuppressLint; import android.app.Activity; import android.os.Bundle; import android.os.Handler; import android.support.v4.widget.SwipeRefreshLayout; import android.support.v4.widget.SwipeRefreshLayout.OnRefreshListener; import android.widget.TextView; public class SimpleActivity extends Activity implements OnRefreshListener { private TextView tv_simple; private SwipeRefreshLayout srl_simple; private Handler mHandler = new Handler(); @SuppressLint("ResourceAsColor") @SuppressWarnings("deprecation") @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_simple); tv_simple = (TextView) findViewById(R.id.tv_simple); srl_simple = (SwipeRefreshLayout) findViewById(R.id.srl_simple); srl_simple.setOnRefreshListener(this); //舊版用下面的setColorScheme設置進度條顏色 srl_simple.setColorScheme(R.color.red, R.color.orange, R.color.green, R.color.blue); //新版用下面的setColorSchemeResources設置進度圓圈顏色 // srl_simple.setColorSchemeResources( // R.color.red, R.color.orange, R.color.green, R.color.blue ); //舊版v4包中無下面三個方法 // srl_simple.setProgressBackgroundColorSchemeResource(R.color.black); // srl_simple.setProgressViewOffset(true, 0, 50); // srl_simple.setDistanceToTriggerSync(100); } @Override public void onRefresh() { tv_simple.setText("正在刷新"); mHandler.postDelayed(mRefresh, 3000); } private Runnable mRefresh = new Runnable() { @Override public void run() { tv_simple.setText("刷新完成"); srl_simple.setRefreshing(false); } }; }
import com.example.exmswipe.adapter.TitleListAdapter; import android.app.Activity; import android.os.Bundle; import android.os.Handler; import android.support.v4.widget.SwipeRefreshLayout; import android.support.v4.widget.SwipeRefreshLayout.OnRefreshListener; import android.view.View; import android.widget.ListView; import android.widget.TextView; public class ListviewActivity extends Activity implements OnRefreshListener { private TextView tv_listview; private SwipeRefreshLayout srl_listview; private Handler mHandler = new Handler(); private ListView lv_content; private String[] yearArray = {"鼠年", "牛年", "虎年", "兔年", "龍年", "蛇年", "馬年", "羊年", "猴年", "雞年", "狗年", "豬年"}; private void refreshView() { TitleListAdapter adapter = new TitleListAdapter(this, yearArray); lv_content.setAdapter(adapter); lv_content.setOnItemClickListener(adapter); lv_content.setOnItemLongClickListener(adapter); } protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_listview); tv_listview = (TextView) findViewById(R.id.tv_listview); srl_listview = (SwipeRefreshLayout) findViewById(R.id.srl_listview); srl_listview.setOnRefreshListener(this); //舊版用下面的setColorScheme設置進度條顏色 srl_listview.setColorScheme(R.color.red, R.color.orange, R.color.green, R.color.blue); //新版用下面的setColorSchemeResources設置進度圓圈顏色 // srl_listview.setColorSchemeResources( // R.color.red, R.color.orange, R.color.green, R.color.blue ); lv_content = (ListView) findViewById(R.id.lv_content); refreshView(); } @Override public void onRefresh() { tv_listview.setVisibility(View.VISIBLE); tv_listview.setText("正在刷新"); mHandler.postDelayed(mRefresh, 3000); } private Runnable mRefresh = new Runnable() { @Override public void run() { refreshView(); tv_listview.setText("刷新完成"); srl_listview.setRefreshing(false); mHandler.postDelayed(mComplete, 500); } }; private Runnable mComplete = new Runnable() { @Override public void run() { tv_listview.setVisibility(View.GONE); } }; }
import java.util.LinkedList; import android.app.Activity; import android.os.Bundle; import android.os.Handler; import android.support.v4.widget.SwipeRefreshLayout; import android.support.v4.widget.SwipeRefreshLayout.OnRefreshListener; import android.support.v7.widget.GridLayoutManager; import android.support.v7.widget.RecyclerView; import android.view.View; import android.widget.TextView; import com.example.exmswipe.adapter.RecyclerAdapter; public class RecyclerActivity extends Activity implements OnRefreshListener { private SwipeRefreshLayout srl_recycler; private Handler mHandler = new Handler(); private int mColumnCount = 3; private RecyclerView rv_content; private GridLayoutManager mLayoutManager; private RecyclerAdapter mAdapter; private String[] yearArray = {"鼠年", "牛年", "虎年", "兔年", "龍年", "蛇年", "馬年", "羊年", "猴年", "雞年", "狗年", "豬年"}; private LinkedList<string> mYearList = new LinkedList<string>(); private void refreshView() { mAdapter = new RecyclerAdapter(this, 2, mYearList); rv_content.setAdapter(mAdapter); mAdapter.setOnItemClickListener(mAdapter); mAdapter.setOnItemLongClickListener(mAdapter); } protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_recycler); srl_recycler = (SwipeRefreshLayout) findViewById(R.id.srl_recycler); srl_recycler.setOnRefreshListener(this); //舊版用下面的setColorScheme設置進度條顏色 srl_recycler.setColorScheme(R.color.red, R.color.orange, R.color.green, R.color.blue); //新版用下面的setColorSchemeResources設置進度圓圈顏色 // srl_recycler.setColorSchemeResources( // R.color.red, R.color.orange, R.color.green, R.color.blue ); rv_content = (RecyclerView) findViewById(R.id.rv_content); mLayoutManager = new GridLayoutManager(this, mColumnCount); mLayoutManager.setSpanSizeLookup(new MySpanRule(-1)); rv_content.setLayoutManager(mLayoutManager); for (int i=0; i<yeararray.length; override="" public="" void="" new="" private="" runnable="" mrefresh="new" mcomplete="new" class="" myspanrule="" extends="" gridlayoutmanager.spansizelookup="" int="" mposition="=" if="" return="" else="" position="=" pre="">
在之前的Android超精准計步器開發-Dylan計步中的首頁用到了一個自定義控件,和QQ運動的界面有點類似,還有動畫效果,下面就來講一下這個View是如何繪制的。1.先
在上一篇文章中我帶著大家一起實現了Android瀑布流照片牆的效果,雖然這種效果很炫很酷,但其實還只能算是一個半成品,因為照片牆中所有的圖片都是只能看不能點的。因此本篇文
本文我們將介紹一些關於Android矢量圖的相關知識點。最新的項目中要求以矢量圖替代傳統的.png資源文件,所以特意學習了一下Android中的矢量圖相關概念,不得不說矢
本文為大家分享了Android bitmap使用細節,供大家參考,具體內容如下1、計算機表示圖形的幾種方式1)BMP :幾乎不進行壓縮 占用空間比較大 2)JPG : 在