我们可以更改在 putextra 的值中写入并在 textview 的 next activity 中分配的文本的大小吗?
Can we change the Size of text which is written in values of putextra and assigned in next activity of textview?
我正在做一个项目,在这个项目中,我将字符串值从一个 activity 导出到第二个 activity,但我无法调整在 [=13] 中分配的字符串值的大小=] 第二个 activity.
第一个代码activity:
if (modelList.get(position).getJtitle().equals("Hello World"))
{
Intent intent = new Intent(mContext,CodeActivity.class);
intent.putExtra("actionBarTitle","Hello World");
intent.putExtra("contentTv","Class HelloWorld\n" +
"{\n" +
"public static void main(String args[])\n" +
"{\n" +
"System.out.println(\"Welcome to Hello World Program\");\n" +
"}\n" +
"}");
mContext.startActivity(intent);
}
第二个 activity 代码:
setContentView(R.layout.activity_jcode);
ActionBar actionBar = getSupportActionBar();
TextView codetv = findViewById(R.id.jtextview);
Intent intent = getIntent();
String mActionBarTitle = intent.getStringExtra("actionBarTitle");
String mContent = intent.getStringExtra("contentTv");
actionBar.setTitle(mActionBarTitle);
codetv.setText(mContent);
}
输出看起来像这样,我们如何更改文本大小:
setContentView(R.layout.activity_jcode);
ActionBar actionBar = getSupportActionBar();
TextView codetv = findViewById(R.id.jtextview);
Intent intent = getIntent();
String mActionBarTitle = intent.getStringExtra("actionBarTitle");
String mContent = intent.getStringExtra("contentTv");
actionBar.setTitle(mActionBarTitle);
codetv.setText(mContent);
codetv.setTextSize(10); //Replace 10 with whatever size you want.
}
为什么不尝试以编程方式将 TextSize 设置为 codetv
或者在.xml布局中静态设置TextView的textSize
我正在做一个项目,在这个项目中,我将字符串值从一个 activity 导出到第二个 activity,但我无法调整在 [=13] 中分配的字符串值的大小=] 第二个 activity.
第一个代码activity:
if (modelList.get(position).getJtitle().equals("Hello World"))
{
Intent intent = new Intent(mContext,CodeActivity.class);
intent.putExtra("actionBarTitle","Hello World");
intent.putExtra("contentTv","Class HelloWorld\n" +
"{\n" +
"public static void main(String args[])\n" +
"{\n" +
"System.out.println(\"Welcome to Hello World Program\");\n" +
"}\n" +
"}");
mContext.startActivity(intent);
}
第二个 activity 代码:
setContentView(R.layout.activity_jcode);
ActionBar actionBar = getSupportActionBar();
TextView codetv = findViewById(R.id.jtextview);
Intent intent = getIntent();
String mActionBarTitle = intent.getStringExtra("actionBarTitle");
String mContent = intent.getStringExtra("contentTv");
actionBar.setTitle(mActionBarTitle);
codetv.setText(mContent);
}
输出看起来像这样,我们如何更改文本大小:
setContentView(R.layout.activity_jcode);
ActionBar actionBar = getSupportActionBar();
TextView codetv = findViewById(R.id.jtextview);
Intent intent = getIntent();
String mActionBarTitle = intent.getStringExtra("actionBarTitle");
String mContent = intent.getStringExtra("contentTv");
actionBar.setTitle(mActionBarTitle);
codetv.setText(mContent);
codetv.setTextSize(10); //Replace 10 with whatever size you want.
}
为什么不尝试以编程方式将 TextSize 设置为 codetv
或者在.xml布局中静态设置TextView的textSize