多线程:
thread,RunThread
MyThread t=new MyThread
t.start();
Thread thread=new Thread(new MyRunThread)
thread.stsrt();
Adapter:
自定义:
public class NewsTestAdapter extends BaseAdapter{
public int getCount() {
return this.mlist==null?0:this.mlist.size();
}
@Override
public NewsContext getItem(int position) {
return this.mlist.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
public View getView(int position, View converView, ViewGroup arg2){
}
}
Fragment:
public class FirstFragement extends Fragment{
@Override
public void onAttach(Activity activity) {
mActivity=activity;
super.onAttach(activity);
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view=inflater.inflate(R.layout.first_fragement, null);
view.findViewById(R.id.fragebtn).setOnClickListener(this);
view.findViewById(R.id.changebtn).setOnClickListener(this);
image=(ImageView) view.findViewById(R.id.frageimage);
return view;
}
}
设置Fragment:
FragmentTransaction ft=getSupportFragmentManager().beginTransaction();
ft.add(R.id.fragmentContainer, new FirstFragement(), "one");
ft.commit();
FragmentTransaction ft=getSupportFragmentManager().beginTransaction();
Fragment hf=getSupportFragmentManager().findFragmentByTag("one");
ft.hide(hf);
ft.commit();
用Fragment实现的滑屏:
public class NewsFragmentAdapter extends FragmentPagerAdapter {
private ArrayList<Fragment> mlist;
public NewsFragmentAdapter(FragmentManager fm, ArrayList<Fragment> mlist) {
super(fm);
this.mlist = mlist;
}
public NewsFragmentAdapter(FragmentManager fm) {
super(fm);
// TODO Auto-generated constructor stub
}
@Override
public Fragment getItem(int position) {
// TODO Auto-generated method stub
return this.mlist.get(position);
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return this.mlist.size();
}
}
thread,RunThread
MyThread t=new MyThread
t.start();
Thread thread=new Thread(new MyRunThread)
thread.stsrt();
Adapter:
自定义:
public class NewsTestAdapter extends BaseAdapter{
public int getCount() {
return this.mlist==null?0:this.mlist.size();
}
@Override
public NewsContext getItem(int position) {
return this.mlist.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
public View getView(int position, View converView, ViewGroup arg2){
}
}
Fragment:
public class FirstFragement extends Fragment{
@Override
public void onAttach(Activity activity) {
mActivity=activity;
super.onAttach(activity);
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view=inflater.inflate(R.layout.first_fragement, null);
view.findViewById(R.id.fragebtn).setOnClickListener(this);
view.findViewById(R.id.changebtn).setOnClickListener(this);
image=(ImageView) view.findViewById(R.id.frageimage);
return view;
}
}
设置Fragment:
FragmentTransaction ft=getSupportFragmentManager().beginTransaction();
ft.add(R.id.fragmentContainer, new FirstFragement(), "one");
ft.commit();
FragmentTransaction ft=getSupportFragmentManager().beginTransaction();
Fragment hf=getSupportFragmentManager().findFragmentByTag("one");
ft.hide(hf);
ft.commit();
用Fragment实现的滑屏:
public class NewsFragmentAdapter extends FragmentPagerAdapter {
private ArrayList<Fragment> mlist;
public NewsFragmentAdapter(FragmentManager fm, ArrayList<Fragment> mlist) {
super(fm);
this.mlist = mlist;
}
public NewsFragmentAdapter(FragmentManager fm) {
super(fm);
// TODO Auto-generated constructor stub
}
@Override
public Fragment getItem(int position) {
// TODO Auto-generated method stub
return this.mlist.get(position);
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return this.mlist.size();
}
}