English 中文(简体)
文本中未改动的案文
原标题:text not changing in a TextView while doing Layout Inflater

在我看来,在活动装满时,我做了以下工作:

setContentView(R.layout.main2);
layoutToAdd = (LinearLayout) findViewById(R.id.linearLayout1);

for(i=0; i<num;i++)
{
    LayoutInflater inflater = LayoutInflater.from(getApplicationContext());
    View view = inflater.inflate(R.layout.camera, null);
    layoutToAdd.addView(view);
}

黄金的价值每次都有所不同。

在我的LayoutInflater布局中,我有案文观点、编辑文本和纽特。

现在,根据num中提及的时代数目显示,现在每次都想改变案文和纽特的名字。 • 如何为文本和Button制定案文。

最佳回答

在你回避布局之后,仅仅确定它们。

View view = inflater.inflate(R.layout.camera, null);
TextView tv = view.findViewById(R.id.textviewid); //id defined in camera.xml
Button b = view.findViewById(R.id.buttonid);      //id defined in camera.xml
tv.setText();
b.setText();
layoutToAdd.addView(view);
问题回答

我所建议的是,你应当建立一个只包含线性语言的Xml档案。

然后,在节目中,You应制作文本意见、EditTexts和Buttons,并添加到电话线上。

您可以确定以下这些组成部分的不同特性:

这里是确定文本表述特性的例子。 对于其他构成部分,青年可以确定相同。

TextView tv=new TextView(context);
tv.setBackgroundResource(R.drawable.textview_bg);
tv.setPadding(20, 5, 40, 5);
tv.setText("set your text");
tv.setLayoutParams(new Gallery.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
tv.setTextColor(Color.RED);
tv.setClickable(true);
tv.setId(id);//where id is an integer which should be unique for each TextView

layout.addView(tv); 

另外,你还需要在休息室内创造和增加这三部分内容,根据您的用途,提供独一无二的ids! 并且,你可以有一套长处,可以把自己的名字放在坡道上,这样,你就更容易地通过你想给他们留下的str。

当你想简单修改清单时,你必须把观点的提及储存在清单中。 参看ById(R.id.text Box_id)。

希望会提供帮助。





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签