Java Code Examples for android.widget.ListView#setTag()

The following examples show how to use android.widget.ListView#setTag() . 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: DialogUnit.java    From Dashchan with Apache License 2.0 5 votes vote down vote up
private void display(DialogProvider dialogProvider) {
	Context context = uiManager.getContext();
	FrameLayout content = new FrameLayout(context);
	ListView listView = new ListView(context);
	content.addView(listView, FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT);
	DialogPostsAdapter adapter = new DialogPostsAdapter(dialogProvider, listView);
	listView.setOnItemClickListener(adapter);
	listView.setOnItemLongClickListener(adapter);
	ScrollListenerComposite.obtain(listView).add(new BusyScrollListener(adapter));
	listView.setAdapter(adapter);
	listView.setId(android.R.id.list);
	listView.setDivider(ResourceUtils.getDrawable(context, R.attr.postsDivider, 0));
	final DialogHolder holder = new DialogHolder(adapter, dialogProvider, content, listView);
	uiManager.observable().register(holder);
	ImageLoader.getInstance().observable().register(holder);
	listView.setTag(holder);
	content.setTag(holder);
	dialogStack.push(content);
	dialogProvider.setStateListener((state) -> {
		switch (state) {
			case STATE_LIST: {
				holder.setShowLoading(false);
				holder.requestUpdate();
				return true;
			}
			case STATE_LOADING: {
				holder.setShowLoading(true);
				return true;
			}
			case STATE_ERROR: {
				if (!holder.cancelled) {
					dialogStack.pop();
					return true;
				}
				return false;
			}
		}
		return false;
	});
}
 
Example 2
Source File: ListScroller.java    From Dashchan with Apache License 2.0 5 votes vote down vote up
private static ListScroller getListScroller(ListView listView, boolean mayCreate) {
	ListScroller listScroller = (ListScroller) listView.getTag(R.id.seek_bar);
	if (listScroller == null && mayCreate) {
		listScroller = new ListScroller(listView);
		listView.setTag(R.id.seek_bar, listScroller);
	}
	return listScroller;
}
 
Example 3
Source File: FindActActivity.java    From letv with Apache License 2.0 4 votes vote down vote up
private void findView() {
    this.mRoot = (PublicLoadLayout) findViewById(R.id.find_act_content_container_layout);
    this.mRoot.addContent(R.layout.activity_find_act_content);
    this.mPullListView = (PullToRefreshListView) this.mRoot.findViewById(R.id.find_act_listView);
    ListView mFindActListView = (ListView) this.mPullListView.getRefreshableView();
    this.mPullListView.setOnRefreshListener(this.onRefreshListener);
    this.mPullListView.setParams(Boolean.valueOf(true), "FindActActivity");
    this.mFindActAdapter = new FindActAdapter(this.mContext, this.mFindChildDataAreaBean);
    mFindActListView.setAdapter(this.mFindActAdapter);
    mFindActListView.setTag(this.mFindActAdapter);
    mFindActListView.setOnItemClickListener(new OnItemClickListener(this) {
        final /* synthetic */ FindActActivity this$0;

        {
            if (HotFix.PREVENT_VERIFY) {
                System.out.println(VerifyLoad.class);
            }
            this.this$0 = this$0;
        }

        public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
            LogInfo.log("Emerson", "------------position = " + position + "---id = " + id);
            FindChildDataAreaBean fcda = (FindChildDataAreaBean) this.this$0.mFindChildDataAreaBean.get((int) id);
            HomeMetaData homeMetaData = new HomeMetaData();
            homeMetaData.at = Integer.valueOf(fcda.at).intValue();
            homeMetaData.mobilePic = fcda.mobilePic;
            homeMetaData.webViewUrl = fcda.webViewUrl;
            homeMetaData.webUrl = fcda.webUrl;
            homeMetaData.nameCn = fcda.nameCn;
            homeMetaData.subTitle = fcda.subTitle;
            homeMetaData.cmsid = fcda.cmsid;
            homeMetaData.duration = fcda.duration;
            homeMetaData.episode = fcda.episode;
            homeMetaData.nowEpisodes = fcda.nowEpisodes;
            homeMetaData.zid = fcda.zid;
            homeMetaData.streamUrl = fcda.streamUrl;
            homeMetaData.streamCode = fcda.streamCode;
            homeMetaData.tag = fcda.tag;
            UIControllerUtils.gotoActivity(this.this$0.mContext, homeMetaData);
        }
    });
    ((ImageView) findViewById(R.id.topic_back_btn)).setOnClickListener(new OnClickListener(this) {
        final /* synthetic */ FindActActivity this$0;

        {
            if (HotFix.PREVENT_VERIFY) {
                System.out.println(VerifyLoad.class);
            }
            this.this$0 = this$0;
        }

        public void onClick(View v) {
            this.this$0.finish();
        }
    });
    this.mRoot.setRefreshData(new RefreshData(this) {
        final /* synthetic */ FindActActivity this$0;

        {
            if (HotFix.PREVENT_VERIFY) {
                System.out.println(VerifyLoad.class);
            }
            this.this$0 = this$0;
        }

        public void refreshData() {
            if (NetworkUtils.isNetworkAvailable()) {
                this.this$0.requestDate(false);
            } else {
                ToastUtils.showToast(this.this$0.mContext, 2131100493);
            }
        }
    });
}
 
Example 4
Source File: UIDataSelector.java    From Auie with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 构建内容视图
 * @return 内容视图
 */
private View createContentView(){
	rootContainer = new LinearLayout(context);
	rootContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
	rootContainer.setBackgroundColor(backgroundColor);
	rootContainer.setOrientation(LinearLayout.VERTICAL);
	topLineView = new View(context);
	topLineView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, (int)(topLineHeight * DP)));
	topLineView.setBackgroundColor(topLineColor);
	dataContainer = new LinearLayout(context);
	dataContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
	dataContainer.setOrientation(LinearLayout.HORIZONTAL);
	dataContainer.setGravity(Gravity.CENTER);
	int paddingPixel = (int)(padding * DP);
	switch (mode) {
	case 3:
		thirdListView = new ListView(context);
		thirdListView.setLayoutParams(new LayoutParams(0, LayoutParams.WRAP_CONTENT, 1));
		thirdListView.setPadding(paddingPixel, paddingPixel, paddingPixel, paddingPixel);
		thirdListView.setSelector(new ColorDrawable(Color.TRANSPARENT));
		thirdListView.setDivider(new ColorDrawable(Color.TRANSPARENT));
		thirdListView.setOnItemClickListener(itemClickListener);
		thirdListView.setAdapter(dataAdapters.get(2));
		thirdListView.setTag(dataAdapters.get(2));
	case 2:
		secondListView = new ListView(context);
		secondListView.setLayoutParams(new LayoutParams(0, LayoutParams.WRAP_CONTENT, 1));
		secondListView.setPadding(paddingPixel, paddingPixel, paddingPixel, paddingPixel);
		secondListView.setSelector(new ColorDrawable(Color.TRANSPARENT));
		secondListView.setDivider(new ColorDrawable(Color.TRANSPARENT));
		secondListView.setOnItemClickListener(itemClickListener);
		secondListView.setAdapter(dataAdapters.get(1));
		secondListView.setTag(dataAdapters.get(1));
	case 1:
		fristListView = new ListView(context);
		fristListView.setLayoutParams(new LayoutParams(0, LayoutParams.WRAP_CONTENT, 1));
		fristListView.setPadding(paddingPixel, paddingPixel, paddingPixel, paddingPixel);
		fristListView.setSelector(new ColorDrawable(Color.TRANSPARENT));
		fristListView.setDivider(new ColorDrawable(Color.TRANSPARENT));
		fristListView.setOnItemClickListener(itemClickListener);
		fristListView.setAdapter(dataAdapters.get(0));
		fristListView.setTag(dataAdapters.get(0));
		break;
	default:
		break;
	}
	
	dataContainer.addView(fristListView);
	if (secondListView != null) {
		leftLineView = new View(context);
		leftLineView.setLayoutParams(new LayoutParams((int)(leftLineWidth * DP), LayoutParams.MATCH_PARENT));
		leftLineView.setBackgroundColor(leftLineColor);
		dataContainer.addView(leftLineView);
		dataContainer.addView(secondListView);
	}
	if (thirdListView != null) {
		rightLineView = new View(context);
		rightLineView.setLayoutParams(new LayoutParams((int)(rightLineWidth * DP), LayoutParams.MATCH_PARENT));
		rightLineView.setBackgroundColor(rightLineColor);
		dataContainer.addView(rightLineView);
		dataContainer.addView(thirdListView);
	}
	rootContainer.addView(topLineView);
	rootContainer.addView(dataContainer);
	
	return rootContainer;
}
 
Example 5
Source File: AnalyzerViews.java    From audio-analyzer-for-android with Apache License 2.0 4 votes vote down vote up
private PopupWindow popupMenuCreate(String[] popUpContents, int resId) {

        // initialize a pop up window type
        PopupWindow popupWindow = new PopupWindow(activity);

        // the drop down list is a list view
        ListView listView = new ListView(activity);

        // set our adapter and pass our pop up window contents
        ArrayAdapter<String> aa = popupMenuAdapter(popUpContents);
        listView.setAdapter(aa);

        // set the item click listener
        listView.setOnItemClickListener(activity);

        // button resource ID, so we can trace back which button is pressed
        listView.setTag(resId);

        // get max text width
        Paint mTestPaint = new Paint();
        mTestPaint.setTextSize(listItemTextSize);
        float w = 0;  // max text width in pixel
        float wi;
        for (String popUpContent : popUpContents) {
            String sts[] = popUpContent.split("::");
            if (sts.length == 0) continue;
            String st = sts[0];
            if (sts.length == 2 && sts[1].equals("0")) {
                mTestPaint.setTextSize(listItemTitleTextSize);
                wi = mTestPaint.measureText(st);
                mTestPaint.setTextSize(listItemTextSize);
            } else {
                wi = mTestPaint.measureText(st);
            }
            if (w < wi) {
                w = wi;
            }
        }

        // left and right padding, at least +7, or the whole app will stop respond, don't know why
        w = w + 23 * DPRatio;
        if (w < 40 * DPRatio) {
            w = 40 * DPRatio;
        }

        // some other visual settings
        popupWindow.setFocusable(true);
        popupWindow.setHeight(WindowManager.LayoutParams.WRAP_CONTENT);
        // Set window width according to max text width
        popupWindow.setWidth((int)w);
        // also set button width
        ((Button) activity.findViewById(resId)).setWidth((int)(w + 5 * DPRatio));
        // Set the text on button in loadPreferenceForView()

        // set the list view as pop up window content
        popupWindow.setContentView(listView);

        return popupWindow;
    }