package com.wangbb.naruto.app.fragment;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import com.wangbb.naruto.R;
import com.wangbb.naruto.app.activity.MainActivity;
import com.wangbb.naruto.app.activity.NewGridViewActivty;
import com.wangbb.naruto.app.activity.NewListViewActivity;
import com.wangbb.naruto.app.activity.NewStaggeredGridActivity;
/**
* Created by wangbinbin on 15/5/9.
*/
public class MainHomeFragment extends BaseFragment implements View.OnClickListener {
private MainActivity mainActivity;
private View view;
private Button likeListview;
private Button likeGridview;
private Button likeStaggeredGrid;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
view = inflater.inflate(R.layout.fragment_main_home, container, false);
initView();
setLisener();
return view;
}
private void setLisener() {
likeListview.setOnClickListener(this);
likeGridview.setOnClickListener(this);
likeStaggeredGrid.setOnClickListener(this);
}
private void initView() {
likeListview = (Button) view.findViewById(R.id.likelistview);
likeGridview = (Button) view.findViewById(R.id.likegridview);
likeStaggeredGrid = (Button) view.findViewById(R.id.likestaggeredgrid);
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
this.mainActivity = (MainActivity) getActivity();
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.likegridview:
startActivity(new Intent(mainActivity, NewGridViewActivty.class));
break;
case R.id.likelistview:
startActivity(new Intent(mainActivity, NewListViewActivity.class));
break;
case R.id.likestaggeredgrid:
startActivity(new Intent(mainActivity, NewStaggeredGridActivity.class));
break;
}
}
}