标签:android style blog http color io os ar java
============问题描述============
/** * 一切为了测试 */ private ExpandTabView expandTabView; private ArrayList<View> mViewArray = new ArrayList<View>(); private ViewMiddle viewMiddle; private void init(){ tv_menu1 = (TextView)findViewById(R.id.tv_menu1); tv_menu2 = (TextView)findViewById(R.id.tv_menu2); tv_menu2.setVisibility(View.GONE); tv_menu3 = (TextView)findViewById(R.id.tv_menu3); tv_menu1.setText(getIntent().getStringExtra("menu")); //获取传过来的分类Id categoryId = getIntent().getStringExtra("id"); tv_menu1.setOnClickListener(this); //tv_menu2.setOnClickListener(this); tv_menu3.setOnClickListener(this); View view = LayoutInflater.from(context).inflate(R.layout.bottom_bar, null); lv_list = (ListView)findViewById(R.id.lv_list_ms); list_list = new ArrayList<HashMap<String,String>>(); list_data3 = new ArrayList<HashMap<String,String>>(); for(int i=0;i<orderNames.length;i++){ HashMap<String,String> map = new HashMap<String, String>(); map.put("name", orderNames[i]); map.put("dictate", orderDictates[i]); list_data3.add(map); } width = getWindowManager().getDefaultDisplay().getWidth(); } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_gastronomy_list); init(); initView(); initVaule(); initListener(); //getProductCategoryList(categoryId); getFLLsit(); getDictList(); getProductList(categoryId,busiareaId,order,pageNo*BASE,(pageNo+1)*BASE); } /** * 一切为了测试 * @param 唉 命苦 */ private void initView() { expandTabView = (ExpandTabView) findViewById(R.id.expandtab_view); // viewLeft = new ViewLeft(this); // getProductCategoryList(""); viewMiddle = new ViewMiddle(this); // viewRight = new ViewRight(this); } private void initVaule() { // mViewArray.add(viewLeft); mViewArray.add(viewMiddle); // mViewArray.add(viewRight); ArrayList<String> mTextArray = new ArrayList<String>(); // mTextArray.add("距离"); mTextArray.add("美食"); if(mViewArray!=null){ Log.i("什么玩意", ""+mViewArray.size()); }else{ Log.i("什么玩意", "呵呵"); } // mTextArray.add("距离"); expandTabView.setValue(mTextArray, mViewArray); //这行报错 空指针 // expandTabView.setTitle(viewLeft.getShowText(), 0); // expandTabView.setTitle(viewMiddle.getShowText(), 1); // expandTabView.setTitle(viewRight.getShowText(), 2); } private void initListener() { // viewLeft.setOnSelectListener(new ViewLeft.OnSelectListener() { // // @Override // public void getValue(String distance, String showText) { // onRefresh(viewLeft, showText); // } // }); viewMiddle.setOnSelectListener(new ViewMiddle.OnSelectListener() { @Override public void getValue(String showText) { onRefresh(viewMiddle, showText); } }); // viewRight.setOnSelectListener(new ViewRight.OnSelectListener() { // @Override // public void getValue(String distance, String showText) { // onRefresh(viewRight, showText); // } // }); } private void onRefresh(View view, String showText) { expandTabView.onPressBack(); int position = getPositon(view); if (position >= 0 && !expandTabView.getTitle(position).equals(showText)) { expandTabView.setTitle(showText, position); } Toast.makeText(getApplicationContext(), showText, Toast.LENGTH_SHORT).show(); } private int getPositon(View tView) { for (int i = 0; i < mViewArray.size(); i++) { if (mViewArray.get(i) == tView) { return i; } } return -1; }
============解决方案1============
============解决方案2============
标签:android style blog http color io os ar java
原文地址:http://www.cnblogs.com/lmyangbk/p/4033823.html