list= new ArrayList<String>(); super.onCreate(savedInstanceState); setContentView(R.layout.fragment_main); //setContentView(R.layout.list); if (savedInstanceState == null) { getFragmentManager().beginTransaction() .add(R.id.container, new PlaceholderFragment()).commit(); } footer = View.inflate(this,R.layout.active,null); activeUser = (ListView) findViewById(R.id.activeUser);//list 活动列表 /** * 第一次添加数据 */ for (int i = 0; i < 10; i++) { Map<String, Object> map = new HashMap<String, Object>(); map.put("PIC", "Test Title"); listItem.add(map); } listItemAdapter = new SimpleAdapter(this, listItem, R.layout.list, new String[] { "PIC" }, new int[] { R.id.textView}); /** * 注册事件 */ // activeUser.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.FILL_PARENT,200)); activeUser.setOnScrollListener(new OnScrollListener() { public void onScrollStateChanged(AbsListView view, int scrollState) { } Thread t =null; @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { // TODO Auto-generated method stub int last = activeUser.getLastVisiblePosition(); if((last+1)==totalItemCount){ activeUser.addFooterView(view, null, false); isLoad = false; t = new Thread(new Runnable() { @Override public void run() { try { Thread.sleep(3000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } ArrayList<HashMap<String, Object>> listItem1 = new ArrayList<HashMap<String, Object>>(); for(int i=200;i<220;i++) { HashMap<String, Object> map = new HashMap<String, Object>(); map.put("ItemTitle", "Level "+i); listItem1.add(map); } //handler.sendMessage(handler.obtainMessage(100,listItem1)); } }); } } Handler handler = new Handler(){ @SuppressWarnings("unchecked") @Override public void handleMessage(Message msg) { // TODO Auto-generated method stub listItem.addAll((ArrayList)msg.obj); listItemAdapter.notifyDataSetChanged(); isLoad =true; // if(activeUser.getFooterViewsCount() >0){ // activeUser.removeFooterView(view); // } } }; }); //reloadDateActive = (ProgressBar)findViewById(R.id.refresh_list_header_progressbar); TextView footer1 = new TextView(this); // activeUser.addFooterView(footer1); /** * 数据包装 */ activeUser.setAdapter(listItemAdapter); // activeUser.removeFooterView(footer1); reload = (ImageView) findViewById(R.id.reload); reload.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub System.out.println("--------------------------------------11111111111111111111111111111111"); Toast.makeText(MainActivity.this, "重新刷新",1).show(); } }); edit = (ImageView) findViewById(R.id.reload); edit.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub Toast.makeText(MainActivity.this, "编辑操作",1).show(); } });
请问启动时候java.lang.RuntimeException: Unable to start activity ComponentInfo{com.chat/com.chat.MainActivity}: java.lang.ClassCastException: android.widget.FrameLayout$LayoutParams cannot be cast to android.widget.AbsListView$LayoutParams
activeUser.setAdapter(listItemAdapter);
执行到这步就报错
明显是需要使用android.widget.AbsListView.LayoutParams,而你使用了另外一个LayoutParams,这句不是已经说明了么?
<preclass="brush:java;toolbar:true;auto-links:false;">android.widget.FrameLayout$LayoutParamscannotbecasttoandroid.widget.AbsListView$LayoutParams
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。