com.zhy.adapter.abslistview.CommonAdapter Java Examples

The following examples show how to use com.zhy.adapter.abslistview.CommonAdapter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ListViewActivity.java    From ViewCapture with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_list_view);
    setActionBarTitle("ListView Capture");
    listView = findViewById(R.id.listView);
    CommonAdapter commonAdapter=new CommonAdapter<String>(this, R.layout.layout_item, Arrays.asList(getResources().getStringArray(R.array.listView_item))) {
        @Override
        protected void convert(ViewHolder viewHolder, String item, int position) {
            TextView textView = viewHolder.getView(R.id.tv);
            textView.setText(item);
        }
    };
    listView.setAdapter(commonAdapter);
    listView.addFooterView(LayoutInflater.from(this).inflate(R.layout.layout_add_item, null));
}
 
Example #2
Source File: HomeMessageFragment.java    From Socket.io-FLSocketIM-Android with MIT License 5 votes vote down vote up
@Override
protected void initView() {
    super.initView();


    adapter = new CommonAdapter<ConversationDbObject>(mContext, R.layout.coversation_list_item, items) {
        @Override
        protected void convert(ViewHolder viewHolder, ConversationDbObject item, int position) {

            viewHolder.setText(R.id.list_user_name, item.getId());
            viewHolder.setText(R.id.list_content, item.getLatestmsgtext());

            String time = TimeUtil.getHourStrTime(item.getLatestmsgtimestamp());
            viewHolder.setText(R.id.list_time, time);
            viewHolder.setText(R.id.list_unreadCount, Integer.toString(item.getUnreadcount()));
            TextView unreadText = viewHolder.getView(R.id.list_unreadCount);
            if (item.getUnreadcount() == 0) {
                unreadText.setVisibility(View.GONE);
            } else {
                unreadText.setVisibility(View.VISIBLE);
            }
        }
    };
    listView.setAdapter(adapter);

    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {

            BaseActivity activity = (BaseActivity)mContext;
            Bundle bundle = new Bundle();
            bundle.putString("username", items.get(i).getId());
            activity.openActivity(ChatActivity.class, bundle);


            // 清空未读消息
            clearUnread(i);
        }
    });
}
 
Example #3
Source File: HomeContactFrament.java    From Socket.io-FLSocketIM-Android with MIT License 5 votes vote down vote up
@Override
protected void initView() {
    super.initView();


    adapter = new CommonAdapter<UserModel>(mContext, R.layout.contact_list_item, users) {
        @Override
        protected void convert(ViewHolder viewHolder, UserModel item, int position) {

            viewHolder.setText(R.id.contact_user_name, item.getName());
            viewHolder.setText(R.id.contact_user_state, item.isOnline()?"[在线]":"[离线]");
        }
    };

    listView.setAdapter(adapter);


    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {

            BaseActivity activity = (BaseActivity)mContext;

            Bundle bundle = new Bundle();
            bundle.putString("username", users.get(i).getName());
            activity.openActivity(ChatActivity.class, bundle);


            clearUnread(i);
        }
    });
}