小编Tai*_*lor的帖子

使用微调器更改android:textColor

我设法spinner在我的代码中使用了一个并希望通过MainActivity该微调器更改文件中某个文本的textColor ,但是它位于另一个类文件中 - Einstellungen.是否可以从另一个活动中更改当前活动中的textColor?

这是main_activity.xml我想要更改文字颜色的地方:

<TextView
    android:id="@+id/speedtext"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="180dp"
    android:gravity="center"
    android:singleLine="true"
    android:text="TEXT"
    android:textColor="@android:color/white"
    android:textSize="220sp" />
Run Code Online (Sandbox Code Playgroud)


这是Einstellungen的活动:

public class Einstellungen extends AppCompatActivity {
    String[] names = {"Weiß", "Blau", "Rot"};
    String[] des = {"Weiß", "Blau", "Rot"};
    ArrayAdapter<String> adapter;
    Spinner spinner;
    TextView description;

    public Button button;

    public void init() {
        button = (Button) findViewById(R.id.button);
        button.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                Intent toy = new Intent(Einstellungen.this, MainActivity.class);
                startActivity(toy);
            }
        });
    }

    protected void onCreate(Bundle …
Run Code Online (Sandbox Code Playgroud)

java android spinner android-studio

5
推荐指数
1
解决办法
127
查看次数

标签 统计

android ×1

android-studio ×1

java ×1

spinner ×1