1)xml中android:textColor="#ccc" ; 2)动态生成时,textView.setText(Html.fromHtml("您好,...
super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) initViews(null) } private fun initViews(view: View?) { mTextView = findViewById(R.id.text_view) as TextView? mTextView?.text = "i have change the text" } } 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. ...
){super.onCreate(savedInstanceState)setContentView(R.layout.activity_main)ck_select.isChecked=false//默认未选中ck_select.setOnCheckedChangeListener{buttonView,isChecked
1. 第一步 :创建自定义Edittext class EditableTextView @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = android.R.attr.editTextStyle //不这样写可能有些属性用不了 ) : AppCompatEditText(context, attrs, defStyleAttr) { init { initView() //在此开始...
"/><Buttonandroid:id="@+id/button"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="change text in textview"android:onClick="Button_onClick"/><Buttonandroid:id="@+id/button2"android:layout_width="wrap_content"android:layout_height="wrap_content"android:...
constantsstaticString nonFinal="non-final";finalString nonStatic="non-static";staticfinalSetmutableCollection=newHashSet();staticfinalImmutableSetmutableElements=ImmutableSet.of(mutable);staticfinalLogger logger=Logger.getLogger(MyClass.getName());staticfinalString[]nonEmptyArray={"these","can","change"...
<TextView android:id="@+id/text1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello World!" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_...
{funonColorChange(newColor:String)}// Step 2: Implement concrete observer classclassLogChemeleonColorObserver:ChemeleonColorObserver{overridefunonColorChange(newColor:String){println("Look, the chemeleon changes to$newColor")}}// Step 3: Create subject classclassChemeleon{varobserver:ChemeleonColor...
因此大家一定会用到 Uber 的开源框架AutoDispose。它其实就是利用View的OnAttachStateChangeListener,当View被拿下的时候,我们就取消所有之前用 RxJava 发出去的请求。 staticfinalclassListenerextendsMainThreadDisposableimplementsView.OnAttachStateChangeListener{privatefinalViewview;privatefinalCompletableObserverobserver;List...
<TextView android:text="@{viewModel.userNameFlow}"... /> 状态监听 使用 Kotlin Flow,你可以监听特定状态的变化,并相应地更新界面。viewModel.userStateFlow.collect { state -> when (state) { is Loading -> showLoading()is Success -> showData(state.data)is Error -> showError(state.error)...