android.widget.ImageButton# setOnClickListener ( ) 源码实例Demo

下面列出了android.widget.ImageButton# setOnClickListener ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: o2oa   文件: PickerAlbumPreviewActivity.java

private void initUI() {
    previewOperationBar = (LinearLayout) findViewById(R.id.picker_image_preview_operator_bar);
    originalImage = (ImageButton) findViewById(R.id.picker_image_preview_orignal_image);
    originalImage.setOnClickListener(this);
    originalImageSizeTip = (TextView) findViewById(R.id.picker_image_preview_orignal_image_tip);
    if (!isSupportOriginal) {
        originalImage.setVisibility(View.INVISIBLE);
        originalImageSizeTip.setVisibility(View.INVISIBLE);
    }
    previewSendBtn = (TextView) findViewById(R.id.picker_image_preview_send);
    previewSendBtn.setOnClickListener(this);
    updateSelectBtnStatus();
    updateOriImageSizeTip(isSendOriginalImage);

    imageViewPager = (ViewPagerFixed) findViewById(R.id.picker_image_preview_viewpager);
    imageViewPager.setOnPageChangeListener(this);
    imageViewPager.setOffscreenPageLimit(2);
    imageViewPagerAdapter = new PickerPreviewPagerAdapter(this, photoLists, getLayoutInflater(),
            imageViewPager.getLayoutParams().width, imageViewPager.getLayoutParams().height, this);
    imageViewPager.setAdapter(imageViewPagerAdapter);

    setTitleIndex(firstDisplayImageIndex);
    updateTitleSelect(firstDisplayImageIndex);
    imageViewPager.setCurrentItem(firstDisplayImageIndex);
}
 

private void initializeNavigationButtons() {
    mPrevButton = (ImageButton) findViewById(R.id.prev);
    mPrevButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            if (mTab.canGoBack()) mTab.goBack();
        }
    });

    mNextButton = (ImageButton) findViewById(R.id.next);
    mNextButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mTab.canGoForward()) mTab.goForward();
        }
    });
}
 

private void loadViews() {
    mVideoView = (VideoView) findViewById(R.id.videoView1);
    mTitleView = (TextView) findViewById(R.id.titleTextView);
    mDescriptionView = (TextView) findViewById(R.id.descriptionTextView);
    mDescriptionView.setMovementMethod(new ScrollingMovementMethod());
    mAuthorView = (TextView) findViewById(R.id.authorTextView);
    mStartText = (TextView) findViewById(R.id.startText);
    mStartText.setText(Utils.formatMillis(0));
    mEndText = (TextView) findViewById(R.id.endText);
    mSeekbar = (SeekBar) findViewById(R.id.seekBar1);
    mPlayPause = (ImageView) findViewById(R.id.playPauseImageView);
    mLoading = (ProgressBar) findViewById(R.id.progressBar1);
    mControllers = findViewById(R.id.controllers);
    mContainer = findViewById(R.id.container);
    mCoverArt = (NetworkImageView) findViewById(R.id.coverArtView);
    ViewCompat.setTransitionName(mCoverArt, getString(R.string.transition_image));
    mPlayCircle = (ImageButton) findViewById(R.id.play_circle);
    mPlayCircle.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            togglePlayback();
        }
    });
}
 
源代码4 项目: FireFiles   文件: MoveFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
	//final Context context = inflater.getContext();

	final View view = inflater.inflate(R.layout.fragment_move, container, false);
	view.findViewById(R.id.background).setBackgroundColor(SettingsActivity.getPrimaryColor(getActivity()));

	mCancel = (ImageButton) view.findViewById(android.R.id.button2);
	mCancel.setOnClickListener(this);

	mMoveInfo = (TextView) view.findViewById(android.R.id.title);
	mMoveInfo.setText("Paste " + FileUtils.formatFileCount(docs.size()) + " in ");
	mMoveInfo.setEnabled(false);
	
	mRootInfo = (TextView) view.findViewById(android.R.id.text1);

	mSave = (ImageButton) view.findViewById(android.R.id.button1);
	mSave.setOnClickListener(this);
	mSave.setEnabled(false);

	mProgress = (MaterialProgressBar) view.findViewById(android.R.id.progress);
	mProgress.setColor(SettingsActivity.getAccentColor());

	return view;
}
 

@Override public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    if (savedInstanceState != null) {
        permissionModel = savedInstanceState.getParcelable(PERMISSION_INSTANCE);
    } else {
        permissionModel = getArguments().getParcelable(PERMISSION_INSTANCE);
    }
    if (permissionModel == null) {
        throw new NullPointerException("Permission Model some how went nuts and become null or was it?.");
    }
    title = (TextView) view.findViewById(R.id.title);
    image = (ImageView) view.findViewById(R.id.image);
    message = (TextView) view.findViewById(R.id.message);
    previous = (ImageButton) view.findViewById(R.id.previous);
    next = (ImageButton) view.findViewById(R.id.next);
    request = (ImageButton) view.findViewById(R.id.request);
    next.setOnClickListener(this);
    previous.setOnClickListener(this);
    request.setOnClickListener(this);
    initViews();
}
 

private void initializeResources() {
  getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
  getSupportActionBar().setCustomView(R.layout.centered_app_title);

  ImageButton okButton = (ImageButton) findViewById(R.id.ok_button);
  passphraseText       = (EditText)    findViewById(R.id.passphrase_edit);
  SpannableString hint = new SpannableString("  " + getString(R.string.PassphrasePromptActivity_enter_passphrase));
  hint.setSpan(new RelativeSizeSpan(0.9f), 0, hint.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
  hint.setSpan(new TypefaceSpan("sans-serif"), 0, hint.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);

  passphraseText.setHint(hint);
  okButton.setOnClickListener(new OkButtonClickListener());
  passphraseText.setOnEditorActionListener(new PassphraseActionListener());
  passphraseText.setImeActionLabel(getString(R.string.prompt_passphrase_activity__unlock),
                                   EditorInfo.IME_ACTION_DONE);
}
 

private void initControllerView(View v) {
  mPauseButton = (ImageButton) v.findViewById(getResources().getIdentifier("mediacontroller_play_pause", "id", mContext.getPackageName()));
  if (mPauseButton != null) {
    mPauseButton.requestFocus();
    mPauseButton.setOnClickListener(mPauseListener);
  }

  mProgress = (SeekBar) v.findViewById(getResources().getIdentifier("mediacontroller_seekbar", "id", mContext.getPackageName()));
  if (mProgress != null) {
    if (mProgress instanceof SeekBar) {
      SeekBar seeker = (SeekBar) mProgress;
      seeker.setOnSeekBarChangeListener(mSeekListener);
    }
    mProgress.setMax(1000);
  }

  mEndTime = (TextView) v.findViewById(getResources().getIdentifier("mediacontroller_time_total", "id", mContext.getPackageName()));
  mCurrentTime = (TextView) v.findViewById(getResources().getIdentifier("mediacontroller_time_current", "id", mContext.getPackageName()));
  mFileName = (TextView) v.findViewById(getResources().getIdentifier("mediacontroller_file_name", "id", mContext.getPackageName()));
  if (mFileName != null)
    mFileName.setText(mTitle);
}
 
源代码8 项目: TextFiction   文件: LibraryAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
	View ret = convertView;
	if (ret == null) {
		LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(
				Context.LAYOUT_INFLATER_SERVICE);
		ret = inflater.inflate(R.layout.library_item, null);
	}
	TextView name = (TextView) ret.findViewById(R.id.gamename);
	ImageButton trash = (ImageButton) ret.findViewById(R.id.btn_delete);
	if (stripSuffix) {
		name.setText(FileUtil.basename(getItem(position)));
	}
	else {
		name.setText(getItem(position).getName());
	}
	trash.setTag(getItem(position));
	trash.setOnClickListener(this);

	return ret;
}
 

ViewHolder(View convertView) {
	super(convertView);
	name = (TextView) convertView.findViewById(R.id.name);
	items = (TextView) convertView.findViewById(R.id.items);
	attr = (TextView) convertView.findViewById(R.id.attr);
	lastModified = (TextView) convertView.findViewById(R.id.lastModified);
	type = (TextView) convertView.findViewById(R.id.type);
	cbx = (ImageButton) convertView.findViewById(R.id.cbx);
	image = (ImageView)convertView.findViewById(R.id.icon);
	more = (ImageButton)convertView.findViewById(R.id.more);
	convertView.setTag(this);
	ll = convertView;

	ll.setOnClickListener(AppsAdapter.this);
	more.setOnClickListener(AppsAdapter.this);
	cbx.setOnClickListener(AppsAdapter.this);

	ll.setOnLongClickListener(AppsAdapter.this);
	more.setOnLongClickListener(AppsAdapter.this);
	cbx.setOnLongClickListener(AppsAdapter.this);
}
 
源代码10 项目: OpenMapKitAndroid   文件: MapActivity.java

protected void initializeMoveNodeButtons() {
    final Button moveNodeBtn = (Button)findViewById(R.id.moveNodeBtn);
    final ImageButton moveNodeMarkerBtn = (ImageButton)findViewById(R.id.moveNodeMarkerBtn);
    View.OnClickListener listener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            osmMap.moveNode();
            toggleMoveNodeMode();
        }
    };
    moveNodeBtn.setOnClickListener(listener);
    moveNodeMarkerBtn.setOnClickListener(listener);
}
 
源代码11 项目: RestaurantApp   文件: StaffDeskActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    setTheme(R.style.AppThemeStaffLogin);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_staff_desk);

    deskListGlobal = new ArrayList<>();

    swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_refresh_layout);
    swipeRefreshLayout.setOnRefreshListener(this);
    swipeRefreshLayout.post(new Runnable() {
                                @Override
                                public void run() {
                                    swipeRefreshLayout.setRefreshing(true);
                                }
                            }
    );

    Request request = new Request(this, url, com.android.volley.Request.Method.GET);
    request.requestVolleyDeskList(this);

    gridView = (GridView) findViewById(R.id.gvDesk);
    gridView.setOnItemClickListener(this);

    getSupportActionBar().setDisplayOptions(android.support.v7.app.ActionBar.DISPLAY_SHOW_CUSTOM);
    getSupportActionBar().setCustomView(R.layout.custom_actionbar);
    tvActionBar = (TextView)getSupportActionBar().getCustomView().findViewById(R.id.tvActionBar);
    ibLogout = (ImageButton) getSupportActionBar().getCustomView().findViewById(R.id.ibLogout);
    ibLogout.setVisibility(View.VISIBLE);
    ibLogout.setOnClickListener(this);
    tvActionBar.setText(getResources().getString(R.string.staffDeskHeader));

    //startService(new Intent(StaffDeskActivity.this, StaffService.class));

}
 
源代码12 项目: FamilyChat   文件: DialPadView.java

private void init(Context context, AttributeSet attrs, int defStyleAttr)
{
    inflate(context, R.layout.layout_dial_pad, this);
    mEdInput = (DigitsEditText) findViewById(R.id.ed_dial_input);
    mEdInput.setKeyListener(UnicodeDialerKeyListener.INSTANCE);
    mEdInput.setOnClickListener(this);
    mEdInput.setOnKeyListener(this);
    mEdInput.setOnLongClickListener(this);
    mEdInput.addTextChangedListener(this);

    mBtnDelete = (ImageButton) findViewById(R.id.btn_dial_input_delete);
    mBtnDelete.setOnClickListener(this);
    mBtnDelete.setOnLongClickListener(this);
    findViewById(R.id.btn_dial_digist_0).setOnClickListener(this);
    findViewById(R.id.btn_dial_digist_1).setOnClickListener(this);
    findViewById(R.id.btn_dial_digist_2).setOnClickListener(this);
    findViewById(R.id.btn_dial_digist_3).setOnClickListener(this);
    findViewById(R.id.btn_dial_digist_4).setOnClickListener(this);
    findViewById(R.id.btn_dial_digist_5).setOnClickListener(this);
    findViewById(R.id.btn_dial_digist_6).setOnClickListener(this);
    findViewById(R.id.btn_dial_digist_7).setOnClickListener(this);
    findViewById(R.id.btn_dial_digist_8).setOnClickListener(this);
    findViewById(R.id.btn_dial_digist_9).setOnClickListener(this);
    findViewById(R.id.btn_dial_digist_star).setOnClickListener(this);
    findViewById(R.id.btn_dial_digist_pound).setOnClickListener(this);
    findViewById(R.id.btn_dial_input_plus).setOnClickListener(this);
    findViewById(R.id.btn_dial_pad_call).setOnClickListener(this);

    //获取震动管理器对象
    mVibratorMgr = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
}
 
源代码13 项目: CSipSimple   文件: ActionMenuItemView.java

@Override
public void onFinishInflate() {

    mImageButton = (ImageButton) findViewById(R.id.abs__imageButton);
    mTextButton = (CapitalizingButton) findViewById(R.id.abs__textButton);
    mImageButton.setOnClickListener(this);
    mTextButton.setOnClickListener(this);
    mImageButton.setOnLongClickListener(this);
    setOnClickListener(this);
    setOnLongClickListener(this);
}
 

private View getTitleView(MainActivity activity, Account account, DirectMessage message) {
    View view = activity.getLayoutInflater().inflate(R.layout.dialog_status_detail, null);
    View messageHeader = view.findViewById(R.id.layout_status_header);
    MessageViewModel statusViewModel = new MessageViewModel(message, account);
    messageHeader = statusViewModel.getView(activity, activity.getLayoutInflater(), messageHeader);
    messageHeader.setClickable(false);
    int background = ((ColorDrawable) messageHeader.getBackground()).getColor();
    view.setBackgroundColor(background);
    ImageButton reply = (ImageButton) view.findViewById(R.id.button_status_detail_reply);
    reply.setOnClickListener(this);
    ImageButton delete = (ImageButton) view.findViewById(R.id.button_status_detail_delete);
    delete.setVisibility(isDeletable(account, message) ? View.VISIBLE : View.GONE);
    delete.setOnClickListener(this);
    ImageButton menuButton = (ImageButton) view.findViewById(R.id.button_status_detail_menu);
    menuButton.setOnClickListener(this);
    LinearLayout commandsLayout = (LinearLayout) view.findViewById(R.id.linearlayout_status_detail_menu);
    commandsLayout.setClickable(true);
    // commands
    ArrayList<Command> commands = getCommands(activity, message, account);
    Command.filter(commands);
    for (final Command command : commands) {
        View commandView = command.getView(activity, activity.getLayoutInflater(), null);
        commandView.setBackgroundColor(getResources().getColor(R.color.transparent));
        commandView.setOnClickListener(new ListItemClickListener(activity, new Runnable() {
            @Override
            public void run() {
                command.execute();
                dismiss();
            }
        }));
        commandsLayout.addView(commandView);
    }
    // status only parts
    view.findViewById(R.id.button_status_detail_retweet).setVisibility(View.GONE);
    view.findViewById(R.id.button_status_detail_favorite).setVisibility(View.GONE);
    view.findViewById(R.id.image_status_detail_fav_count).setVisibility(View.GONE);
    view.findViewById(R.id.image_status_detail_rt_count).setVisibility(View.GONE);
    return view;
}
 
源代码15 项目: test-samples   文件: PT_PingTest.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.pt_layout);

    inputMethodManager = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE);

    et_host = (EditText) findViewById(R.id.pt_et_host);
    et_pingCount = (EditText) findViewById(R.id.pt_et_pingCount);
    ib_pingCountIncrement = (ImageButton) findViewById(R.id.pt_ib_pingCountIncrement);
    ib_pingCountDecrement = (ImageButton) findViewById(R.id.pt_ib_pingCountDecrement);
    b_ping = (Button) findViewById(R.id.pt_b_ping);
    pb_pinging = (ProgressBar) findViewById(R.id.pt_pb_pinging);
    tv_status = (TextView) findViewById(R.id.pt_tv_status);
    tv_min = (TextView) findViewById(R.id.pt_tv_min);
    tv_avg = (TextView) findViewById(R.id.pt_tv_avg);
    tv_max = (TextView) findViewById(R.id.pt_tv_max);
    tv_sd = (TextView) findViewById(R.id.pt_tv_sd);
    tv_output = (TextView) findViewById(R.id.pt_tv_output);

    b_ping.setOnClickListener(this);
    ib_pingCountIncrement.setOnClickListener(this);
    ib_pingCountDecrement.setOnClickListener(this);

    et_host.setInputType(InputType.TYPE_TEXT_VARIATION_URI);
    et_pingCount.setInputType(InputType.TYPE_CLASS_NUMBER);

    // don't auto-pop keyboard
    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

    // setting presets
    et_pingCount.setText("" + Constants.PING_COUNT_DEFAULT);


}
 
源代码16 项目: Rumble   文件: FragmentNetworkDrawer.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Log.d(TAG, "onCreateView");
    mDrawerFragmentLayout = (LinearLayout)inflater.inflate(R.layout.fragment_network_drawer, container, false);

    // create the multistate bluetooth controller
    bluetoothController   = (MultiStateButton)mDrawerFragmentLayout.findViewById(R.id.bluetooth_controller);
    bluetoothController.addState(R.drawable.ic_bluetooth_disabled_white_18dp);
    bluetoothController.addState(R.drawable.ic_bluetooth_white_18dp);
    bluetoothController.addState(R.drawable.ic_bluetooth_searching_white_18dp);
    bluetoothController.setOnMultiStateClickListener(bluetoothControllerClick);

    // create the multistate wifi controller
    wifiController   = (MultiStateButton)mDrawerFragmentLayout.findViewById(R.id.wifi_controller);
    wifiController.addState(R.drawable.ic_signal_wifi_off_white_18dp);
    wifiController.addState(R.drawable.ic_signal_wifi_4_bar_white_18dp);
    wifiController.addState(R.drawable.ic_wifi_tethering_white_18dp);
    wifiController.setOnMultiStateClickListener(wifiControllerClick);

    // set the force scan button to refresh neighborhood
    forceScan       = (ImageButton)  mDrawerFragmentLayout.findViewById(R.id.scanningButton);
    forceScan.setOnClickListener(onForceScanClicked);

    // bind to the networkCoordinator service
    Intent intent = new Intent(getActivity(), NetworkCoordinator.class);
    getActivity().bindService(intent, mConnection, Context.BIND_AUTO_CREATE);

    return mDrawerFragmentLayout;
}
 

public void initUI() {
        LinearLayout parent = EditManager.INSTANCE.getToolsLayout();
        parent.removeAllViews();

        Context context = parent.getContext();
        IEditableLayer editLayer = EditManager.INSTANCE.getEditLayer();
        int padding = 2;

        if (editLayer != null) {
            deleteFeatureButton = new ImageButton(context);
            deleteFeatureButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.WRAP_CONTENT));
            deleteFeatureButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_delete_line_feature_24dp));
            deleteFeatureButton.setPadding(0, padding, 0, padding);
            deleteFeatureButton.setOnTouchListener(this);
            deleteFeatureButton.setOnClickListener(this);
            parent.addView(deleteFeatureButton);

//            copyFeatureButton = new ImageButton(context);
//            copyFeatureButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
//                    LayoutParams.WRAP_CONTENT));
//            copyFeatureButton.setBackground(context.getDrawable(R.drawable.editing_copy_geoms));
//            copyFeatureButton.setPadding(0, padding, 0, padding);
//            copyFeatureButton.setOnTouchListener(this);
//            copyFeatureButton.setOnClickListener(this);
//            parent.addView(copyFeatureButton);

            continueLineFeatureButton = new ImageButton(context);
            continueLineFeatureButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.WRAP_CONTENT));
            continueLineFeatureButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_continue_line_24dp));
            continueLineFeatureButton.setPadding(0, padding, 0, padding);
            continueLineFeatureButton.setOnClickListener(this);
            continueLineFeatureButton.setOnTouchListener(this);
            parent.addView(continueLineFeatureButton);

            editAttributesButton = new ImageButton(context);
            editAttributesButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.WRAP_CONTENT));
            editAttributesButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_view_attributes_24dp));
            editAttributesButton.setPadding(0, padding, 0, padding);
            editAttributesButton.setOnTouchListener(this);
            editAttributesButton.setOnClickListener(this);
            parent.addView(editAttributesButton);

            undoButton = new ImageButton(context);
            undoButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
            undoButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_undo_24dp));
            undoButton.setPadding(0, padding, 0, padding);
            undoButton.setOnTouchListener(this);
            undoButton.setOnClickListener(this);
            parent.addView(undoButton);

            commitButton = new ImageButton(context);
            commitButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
            commitButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_commit_24dp));
            commitButton.setPadding(0, padding, 0, padding);
            commitButton.setOnTouchListener(this);
            commitButton.setOnClickListener(this);
            parent.addView(commitButton);
            commitButton.setVisibility(View.GONE);
        }
    }
 
源代码18 项目: RobotCA   文件: RobotInfoAdapter.java

/**
 * Creates a ViewHolder for the specified View.
 * @param v The View
 */
public ViewHolder(View v) {
    super(v);
    v.setClickable(true);
    v.setOnClickListener(this);
    mRobotNameTextView = (TextView) v.findViewById(R.id.robot_name_text_view);
    mMasterUriTextView = (TextView) v.findViewById(R.id.master_uri_text_view);

    mEditButton = (ImageButton) v.findViewById(R.id.robot_edit_button);
    mEditButton.setOnClickListener(this);

    mDeleteButton = (ImageButton) v.findViewById(R.id.robot_delete_button);
    mDeleteButton.setOnClickListener(this);

    mImageView = (ImageView) v.findViewById(R.id.robot_wifi_image);
    mImageView.setImageResource(R.drawable.wifi_0);

    Timer t = new Timer();

    t.scheduleAtFixedRate(new TimerTask() {

        @Override
        public void run() {
            try {
                int position = getAdapterPosition();
                final RobotInfo info = mDataset.get(position);
                //mImageView.setLayoutParams(new ActionBar.LayoutParams(mEditButton.getHeight(), mEditButton.getHeight()));

                if (isPortOpen(info.getUri().getHost(), info.getUri().getPort(), 10000)) {
                    activity.runOnUiThread(new Runnable() {

                        @Override
                        public void run() {
                            mImageView.setImageResource(R.drawable.wifi_4);
                        }
                    });
                } else {
                    activity.runOnUiThread(new Runnable() {

                        @Override
                        public void run() {
                            mImageView.setImageResource(R.drawable.wifi_0);
                        }
                    });
                }

                Thread.sleep(10000);
            } catch (Exception ignore) {

            }
        }
    }, 1000, 15000);
}
 

@Override
protected void onCreate(Bundle savedInstanceState) {
    ListView messageHistory;
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_play);
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    DrawerLayout drawer = findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open,
            R.string.navigation_drawer_close);
    drawer.addDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = findViewById(R.id.nav_view);
    channelMenu = navigationView.getMenu();
    navigationView.setNavigationItemSelectedListener(this);
    initChannels();

    GoogleSignInOptions.Builder gsoBuilder =
            new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                    .requestIdToken(getString(R.string.default_web_client_id))
                    .requestEmail();

    GoogleSignInOptions gso = gsoBuilder.build();
    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .enableAutoManage(this, this)
            .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
            .build();

    SignInButton signInButton = findViewById(R.id.sign_in_button);
    signInButton.setSize(SignInButton.SIZE_STANDARD);
    signInButton.setOnClickListener(this);
    channelLabel = findViewById(R.id.channelLabel);
    Button signOutButton = findViewById(R.id.sign_out_button);
    signOutButton.setOnClickListener(this);

    ImageButton microphoneButton = findViewById(R.id.microphone_button);
    microphoneButton.setOnClickListener(this);

    messages = new ArrayList<>();
    messageAdapter = new SimpleAdapter(this, messages, android.R.layout.simple_list_item_2,
            new String[]{"message", "meta"},
            new int[]{android.R.id.text1, android.R.id.text2});

    messageHistory = findViewById(R.id.messageHistory);
    messageHistory.setOnItemClickListener(this);
    messageHistory.setAdapter(messageAdapter);
    messageText = findViewById(R.id.messageText);
    messageText.setOnKeyListener(this);
    fmt = new SimpleDateFormat("yy.MM.dd HH:mm z", Locale.US);

    status = findViewById(R.id.status);
}
 
源代码20 项目: RichEditText   文件: RichEditText.java

private void setupView(Context context, AttributeSet attrs, int defStyleAttr,int defStyleRes){
        _context = context;
        RelativeLayout relativeLayout = new RelativeLayout(context);
        RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                LayoutParams.MATCH_PARENT);

        EditText editText = new EditText(context,attrs);

        editText.setId(EDIT_TEXT_ID);
        //
        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.RichEditText);
        mRichEditEnabled = a.getBoolean(R.styleable.RichEditText_richEditAble,true);
        a.recycle();

        mImageButton = new ImageButton(context);
        int px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 24, getResources().getDisplayMetrics());
        RelativeLayout.LayoutParams editToggleParams = new RelativeLayout.LayoutParams(px,px);
        mImageButton.setBackground(getResources().getDrawable(R.drawable.ic_keyboard_arrow_left_black_24dp));
        editToggleParams.addRule(RelativeLayout.ALIGN_BOTTOM, EDIT_TEXT_ID);
        editToggleParams.addRule(RelativeLayout.ALIGN_RIGHT, EDIT_TEXT_ID);
        mImageButton.setLayoutParams(editToggleParams);
        mImageButton.setId(EDIT_TOGGLE_ID);
        mImageButton.setRotation(-90);
        mImageButton.setOnClickListener(this);

        View htmlOptions = inflate(context,R.layout.htmloptions,null);

        RelativeLayout.LayoutParams htmlOptionsLayoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.WRAP_CONTENT);

        htmlOptionsLayoutParams.addRule(RelativeLayout.BELOW, 1001);
        htmlOptionsLayoutParams.addRule(RelativeLayout.ALIGN_RIGHT, 1001);

        htmlOptions.setLayoutParams(htmlOptionsLayoutParams);
        relativeLayout.setLayoutParams(params);
        relativeLayout.addView(editText);
        relativeLayout.addView(mImageButton);

        //htmlOptions.setVisibility(View.GONE);
        if(mRichEditEnabled) {
            relativeLayout.addView(htmlOptions);
        }
        addView(relativeLayout);

        this.mEditText = editText;
        if(mRichEditEnabled) {
            findViewById(R.id.makeBold).setOnClickListener(this);
            findViewById(R.id.makeItalic).setOnClickListener(this);
            findViewById(R.id.makeUnderline).setOnClickListener(this);
            findViewById(R.id.makeBackground).setOnClickListener(this);
            findViewById(R.id.makeForeground).setOnClickListener(this);
            findViewById(R.id.makeHyperlink).setOnClickListener(this);
            findViewById(R.id.makeStrikethrough).setOnClickListener(this);
            findViewById(R.id.makeScaleX).setOnClickListener(this);
            mHtmloptions = (LinearLayout) findViewById(R.id.rich_toolbar);
            mHtmloptions.setVisibility(View.GONE);
//            mImageButton = (ImageButton) findViewById(R.id.list_toggle);
//            mImageButton.setOnClickListener(this);
        }
        this.mEditText.setOnClickListener(this);
        setOnClickListener(this);
        mSS = new SpannableStringBuilder(mEditText.getText());

    }