标签:不能 技术分享 over apk rap inf horizon cti .com
布局文件:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context=".MainActivity"> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="20dp"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="集体业务一:" /> <TextView android:id="@+id/tv_operation1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="@android:color/black" android:textColorHint="@android:color/black" android:layout_centerHorizontal="true" android:text="测试值" /> </RelativeLayout> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="20dp"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="集体业务二:" /> <TextView android:id="@+id/tv_operation2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="@android:color/black" android:textColorHint="@android:color/black" android:layout_centerHorizontal="true" android:text="测试值" /> </RelativeLayout> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="20dp"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="集体业务三:" /> <TextView android:id="@+id/tv_operation3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="@android:color/black" android:textColorHint="@android:color/black" android:layout_centerHorizontal="true" android:text="测试值" /> </RelativeLayout> </LinearLayout>
Activity文件:
package liudeli.my_work_summary; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.TextView; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); initView(); } private void initView() { TextView tvOperation1 = findViewById(R.id.tv_operation1); TextView tvOperation2 = findViewById(R.id.tv_operation2); TextView tvOperation3 = findViewById(R.id.tv_operation3); tvOperation1.setHint("工作业务数据1...."); tvOperation2.setHint("工作业务数据2...."); tvOperation3.setHint("工作业务数据3...."); } }
结果:结果却是设置无效;
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context=".MainActivity"> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="20dp"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="集体业务一:" /> <TextView android:id="@+id/tv_operation1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="@android:color/black" android:textColorHint="@android:color/black" android:layout_centerHorizontal="true" /> </RelativeLayout> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="20dp"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="集体业务二:" /> <TextView android:id="@+id/tv_operation2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="@android:color/black" android:textColorHint="@android:color/black" android:layout_centerHorizontal="true" /> </RelativeLayout> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="20dp"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="集体业务三:" /> <TextView android:id="@+id/tv_operation3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="@android:color/black" android:textColorHint="@android:color/black" android:layout_centerHorizontal="true" /> </RelativeLayout> </LinearLayout>
package liudeli.my_work_summary; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.TextView; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); initView(); } private void initView() { TextView tvOperation1 = findViewById(R.id.tv_operation1); TextView tvOperation2 = findViewById(R.id.tv_operation2); TextView tvOperation3 = findViewById(R.id.tv_operation3); /* tvOperation1.setHint("工作业务数据1...."); tvOperation2.setHint("工作业务数据2...."); tvOperation3.setHint("工作业务数据3...."); */ tvOperation1.setText("工作业务数据1...."); tvOperation2.setText("工作业务数据2...."); tvOperation3.setText("工作业务数据3...."); } }
Android-工作总结-LX-2018-08-20-setHint
标签:不能 技术分享 over apk rap inf horizon cti .com
原文地址:https://www.cnblogs.com/android-deli/p/10164486.html