我在XML基础视图。
I have a base view in XML.
<RelativeLayout android:id="@+id/RelativeLayout01" android:layout_width="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="wrap_content"><TextView android:layout_height="wrap_content" android:layout_width="fill_parent" android:text="Family" android:id="@+id/Family" android:textSize="16px" android:padding="5px" android:textStyle="bold" android:gravity="center_horizontal"></TextView>
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/Family" android:layout_alignRight="@+id/Family" android:text="@string/context_notion_level_off" android:id="@+id/ContextNotionLevel"></TextView>
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toLeftOf="@+id/Detailed" android:layout_below="@+id/Family" android:layout_alignLeft="@+id/Family" android:textStyle="bold" android:id="@+id/Module" android:text="Location"></TextView>
<SeekBar android:layout_height="wrap_content" android:id="@+id/SeekBar01" android:layout_width="fill_parent" android:padding="5px" android:saveEnabled="true" android:layout_below="@+id/Module" android:max="2"></SeekBar>
</RelativeLayout>
我
如何能重复部分X倍下,看起来像这里:
How can I repeat the section X times under, to look like here:
那么,我怎么能访问搜索栏的所有项目? 请注意,我想这是动态的工作,例如:15次。
Then, how can I access the seekbar for all items? Please note that I want this to be dynamical to work eg: for 15 times.
如何将能够得到名(位置),设定值(搜索栏的值),和检索值对于每个组
How will be able to give a name(Location), set value(seekbar value), and retrieve value for each group.
从你的照片,你不想重复家庭称号
From the picture you have, you dont want to repeat the "Family" title
你可以做的就是创建一个包含布局和标题一个新的XML(mymain.xml)
What you can do is create a new xml (mymain.xml) containing a layout and the title
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:orientation="vertical" android:id="@+id/myMainLayout" android:layout_width="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="wrap_content">
<TextView android:layout_height="wrap_content" android:layout_width="fill_parent" android:text="Family" android:id="@+id/Family" android:textSize="16px" android:padding="5px" android:textStyle="bold" android:gravity="center_horizontal"></TextView>
</LinearLayout>
然后在另一个XML(myviews.xml),把你已经把从OP的XML(标题为删除)
Then in another xml (myviews.xml), put the xml you have put from your OP (with the title removed)
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:id="@+id/RelativeLayout01"
android:layout_width="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content">
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" android:textStyle="bold"
android:id="@+id/Module" android:text="Location">
</TextView>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="context_notion_level_off"
android:layout_alignRight="@+id/Module" android:id="@+id/ContextNotionLevel">
</TextView>
<SeekBar android:layout_height="wrap_content" android:id="@+id/SeekBar01"
android:layout_width="fill_parent" android:padding="5px"
android:saveEnabled="true" android:layout_below="@+id/Module"
android:max="2">
</SeekBar>
</RelativeLayout>
和活动:
super.onCreate(savedInstanceState);
setContentView(R.layout.mymain);
LinearLayout l = (LinearLayout) findViewById(R.id.myMainLayout);
LayoutInflater linflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
for(int i = 0 ; i < 15; i++) {
View myView = linflater.inflate(R.layout.myviews, null);
SeekBar s = (SeekBar) myView.findViewById(R.id.SeekBar01);
//Set an id to know which seekbar is in use
s.setId(i);
TextView t = (TextView) myView.findViewById(R.id.Module);
//Change name dynamically
t.setText(("My location " + i).toString());
s.setOnSeekBarChangeListener(new OnSeekBarChangeListener(){
@Override
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {
Log.i("=========","My SeekBar = " + seekBar.getId());
Log.i("=========","My Progress = " + progress);
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
}});
l.addView(myView);
}
编辑:
要从mymain.xml添加滚动条,加上周围的LinearLayout滚动型标签
To add scroll bars, add ScrollView tags around the LinearLayout from your mymain.xml
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:orientation="vertical" android:scrollbars="vertical">
<LinearLayout android:orientation="vertical" android:id="@+id/myMainLayout" android:layout_width="fill_parent" android:layout_height="wrap_content">
<TextView android:layout_height="wrap_content" android:layout_width="fill_parent" android:text="Family" android:id="@+id/Family" android:textSize="16px" android:padding="5px" android:textStyle="bold" android:gravity="center_horizontal"></TextView>
</LinearLayout>
</ScrollView>
上一篇:可活动收到无序广播(来电)意图系统的默认接收过吗?意图、系统
下一篇:在机器人的Picasa访问:PicasaUploadActivity机器人、Picasa、PicasaUploadActivity