XML
<TabHost
android:id="@+id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<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" >
<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</TabWidget>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:id="@+id/tab1"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="@+id/tvOffice"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Office Location"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold"
tools:ignore="HardcodedText" />
<TextView
android:id="@+id/tvOfficeLocation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tvOffice"
android:text="Smart Technologies, Inc. is currently located at:"
tools:ignore="HardcodedText" />
<TextView
android:id="@+id/tvOfficeAdd1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tvOfficeLocation"
android:text="201 South Eagle Lane"
tools:ignore="HardcodedText" />
<TextView
android:id="@+id/tvOfficeAdd2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tvOfficeAdd1"
android:text="Smart Technologies, Inc. is currently located at:"
tools:ignore="HardcodedText" />
<TextView
android:id="@+id/tvMap"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tvOfficeAdd2"
android:text="View Map"
tools:ignore="HardcodedText" />
<Button
android:id="@+id/bMap"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tvMap"
android:text="Map"
tools:ignore="HardcodedText" />
<TextView
android:id="@+id/tvPhone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/bMap"
android:text="Contact Phone Numbers"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold"
tools:ignore="HardcodedText" />
<Button
android:id="@+id/bCallOffice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tvPhone"
android:text="Call Office"
tools:ignore="HardcodedText" />
<Button
android:id="@+id/bCallTollFree"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/bCallOffice"
android:text="Call Toll Free"
tools:ignore="HardcodedText" />
</RelativeLayout>
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<RelativeLayout
android:id="@+id/tab2"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="@+id/ivStef"
android:layout_width="208dp"
android:layout_height="208dp"
android:layout_alignParentLeft="true"
android:contentDescription="Stef"
android:src="@drawable/yellow_bird_icon"
tools:ignore="HardcodedText" />
<TextView
android:id="@+id/tvStef"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/ivStef"
android:text="Stephaine Smith"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold"
tools:ignore="HardcodedText" />
<TextView
android:id="@+id/tvStefTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tvStef"
android:text="Sales"
tools:ignore="HardcodedText" />
<Button
android:id="@+id/bCallStef"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tvStefTitle"
android:text="Call Stephanie"
tools:ignore="HardcodedText" />
<Button
android:id="@+id/bEmailStef"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/bCallStef"
android:text="Email Stephanie"
tools:ignore="HardcodedText" />
<ImageView
android:id="@+id/ivGRay"
android:layout_width="208dp"
android:layout_height="208dp"
android:layout_alignParentLeft="true"
android:layout_below="@+id/bEmailStef"
android:contentDescription="G Ray"
android:src="@drawable/green_bird_icon"
tools:ignore="HardcodedText" />
<TextView
android:id="@+id/tvGRay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/ivGRay"
android:text="Gerald Ray"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold"
tools:ignore="HardcodedText" />
<TextView
android:id="@+id/tvGRayTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tvGRay"
android:text="Sales/RCDD"
tools:ignore="HardcodedText" />
<Button
android:id="@+id/bCallGRay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tvGRayTitle"
android:text="Call Gerald"
tools:ignore="HardcodedText" />
<Button
android:id="@+id/bEmailGRay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/bCallGRay"
android:text="Email Gerald"
tools:ignore="HardcodedText" />
</RelativeLayout>
</ScrollView>
<RelativeLayout
android:id="@+id/tab3"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="@+id/ivJeremy"
android:layout_width="208dp"
android:layout_height="208dp"
android:layout_alignParentLeft="true"
android:contentDescription="Jeremy"
android:src="@drawable/red_bird_icon"
tools:ignore="HardcodedText" />
<TextView
android:id="@+id/tvJeremy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/ivJeremy"
android:text="Jeremy Walck"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold"
tools:ignore="HardcodedText" />
<TextView
android:id="@+id/tvJeremyTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tvJeremy"
android:text="Cabling Supervisor/ Vice President"
tools:ignore="HardcodedText" />
<Button
android:id="@+id/bCallJeremy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tvJeremyTitle"
android:text="Call Jeremy"
tools:ignore="HardcodedText" />
<Button
android:id="@+id/bEmailJeremy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/bCallJeremy"
android:text="Email Jeremy"
tools:ignore="HardcodedText" />
</RelativeLayout>
<ScrollView
android:id="@+id/scrollView3"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<RelativeLayout
android:id="@+id/tab4"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="@+id/ivJerry"
android:layout_width="208dp"
android:layout_height="208dp"
android:layout_alignParentLeft="true"
android:contentDescription="Jerry"
android:src="@drawable/black_bird_icon"
tools:ignore="HardcodedText" />
<TextView
android:id="@+id/tvJerry"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/ivJerry"
android:text="Jerry Hedrick"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold"
tools:ignore="HardcodedText" />
<TextView
android:id="@+id/tvJerryTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tvJerry"
android:text="Network Administrator / Vice Presedent"
tools:ignore="HardcodedText" />
<Button
android:id="@+id/bCallJerry"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tvJerryTitle"
android:text="Call Jerry"
tools:ignore="HardcodedText" />
<Button
android:id="@+id/bEmailJerry"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/bCallJerry"
android:text="Email Jerry"
tools:ignore="HardcodedText" />
<ImageView
android:id="@+id/ivTanner"
android:layout_width="208dp"
android:layout_height="208dp"
android:layout_alignParentLeft="true"
android:layout_below="@+id/bEmailJerry"
android:contentDescription="Tanner"
android:src="@drawable/blue_bird_icon"
tools:ignore="HardcodedText" />
<TextView
android:id="@+id/tvTanner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/ivTanner"
android:text="Tanner Hughes"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold"
tools:ignore="HardcodedText" />
<TextView
android:id="@+id/tvTannerTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tvTanner"
android:text="Network Administrator"
tools:ignore="HardcodedText" />
<Button
android:id="@+id/bCallTanner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tvTannerTitle"
android:text="Call Tanner"
tools:ignore="HardcodedText" />
<Button
android:id="@+id/bEmailTanner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/bCallTanner"
android:text="Email Tanner"
tools:ignore="HardcodedText" />
</RelativeLayout>
</ScrollView>
</FrameLayout>
</LinearLayout>
</TabHost>
爪哇
public class Contact extends Activity实现View.OnClickListener {
TabSpec specs, specs2, specs3, specs4;
Button cStef, eStef, cGRay, eGRay, cJeremy, eJeremy, cJerry, eJerry,
cTanner, eTanner, cOffice, cTollFree, MapOffice;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
// fullScreen
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.contact);
TabHost th = (TabHost) findViewById(R.id.tabhost);
th.setup();
// tab2 setup
specs = th.newTabSpec("office");
specs.setContent(R.id.tab1);
specs.setIndicator("Office");
th.addTab(specs);
// tab2 setup
specs2 = th.newTabSpec("sales");
specs2.setContent(R.id.tab2);
specs2.setIndicator("Sales");
th.addTab(specs2);
// tab2 setup
specs3 = th.newTabSpec("cabling");
specs3.setContent(R.id.tab3);
specs3.setIndicator("Cabling");
th.addTab(specs3);
// tab3 setup
specs4 = th.newTabSpec("service");
specs4.setContent(R.id.tab4);
specs4.setIndicator("Service");
th.addTab(specs4);
initialize();
}
private void initialize() {
// TODO Auto-generated method stub
MapOffice = (Button) findViewById(R.id.bMap);
cOffice = (Button) findViewById (R.id.bCallOffice);
cTollFree = (Button) findViewById (R.id.bCallTollFree);
cStef = (Button) findViewById(R.id.bCallStef);
eStef = (Button) findViewById(R.id.bEmailStef);
cGRay = (Button) findViewById(R.id.bCallGRay);
eGRay = (Button) findViewById(R.id.bEmailGRay);
cJeremy = (Button) findViewById(R.id.bCallJeremy);
eJeremy = (Button) findViewById(R.id.bEmailJeremy);
cJerry = (Button) findViewById(R.id.bCallJerry);
eJerry = (Button) findViewById(R.id.bEmailJerry);
cTanner = (Button) findViewById(R.id.bCallTanner);
eTanner = (Button) findViewById(R.id.bEmailTanner);
MapOffice.setOnClickListener(this);
cOffice.setOnClickListener(this);
cTollFree.setOnClickListener(this);
cStef.setOnClickListener(this);
eStef.setOnClickListener(this);
cGRay.setOnClickListener(this);
eGRay.setOnClickListener(this);
cJeremy.setOnClickListener(this);
eJeremy.setOnClickListener(this);
cJerry.setOnClickListener(this);
eJerry.setOnClickListener(this);
cTanner.setOnClickListener(this);
eTanner.setOnClickListener(this);
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
final Intent callOffice = new Intent(Intent.ACTION_CALL);
callOffice.setData(Uri.parse("tel:4057877878"));
switch (v.getId()) {
//Tab 1
case R.id.bMap:
break;
case R.id.bCallOffice:
startActivity(callOffice);
finish();
break;
case R.id.bCallTollFree:
Intent callToll = new Intent(Intent.ACTION_CALL);
callToll.setData(Uri.parse("tel:18006461423"));
startActivity(callToll);
finish();
break;
// Tab 2
case R.id.bCallStef:
startActivity(callOffice);
finish();
break;
case R.id.bEmailStef:
Intent emailStef = new Intent(Intent.ACTION_SEND);
emailStef.putExtra(Intent.EXTRA_EMAIL,
new String[] { "ssmith@smart-technologies.com" });
emailStef
.putExtra(Intent.EXTRA_TEXT,
"This Email was sent by the Smart Technologies Android Application");
emailStef.setType("text/plain");
startActivity(emailStef);
finish();
break;
case R.id.bCallGRay:
startActivity(callOffice);
finish();
break;
case R.id.bEmailGRay:
Intent emailGRay = new Intent(Intent.ACTION_SEND);
emailGRay.putExtra(Intent.EXTRA_EMAIL,
new String[] { "Gray@smart-technologies.com" });
emailGRay
.putExtra(Intent.EXTRA_TEXT,
"This Email was sent by the Smart Technologies Android Application");
emailGRay.setType("text/plain");
startActivity(emailGRay);
finish();
break;
// Tab 3
}
switch (v.getId()) {
case R.id.bCallJeremy:
startActivity(callOffice);
finish();
break;
case R.id.bEmailJeremy:
Intent emailJeremy = new Intent(Intent.ACTION_SEND);
emailJeremy.putExtra(Intent.EXTRA_EMAIL,
new String[] { "jwalck@smart-technologies.com" });
emailJeremy
.putExtra(Intent.EXTRA_TEXT,
"This Email was sent by the Smart Technologies Android Application");
emailJeremy.setType("text/plain");
startActivity(emailJeremy);
finish();
break;
// Tab 4
}
switch (v.getId()) {
case R.id.bCallJerry:
startActivity(callOffice);
finish();
break;
case R.id.bEmailJerry:
Intent emailJerry = new Intent(Intent.ACTION_SEND);
emailJerry.putExtra(Intent.EXTRA_EMAIL,
new String[] { "jhedrick@smart-technologies.com" });
emailJerry
.putExtra(Intent.EXTRA_TEXT,
"This Email was sent by the Smart Technologies Android Application");
emailJerry.setType("text/plain");
startActivity(emailJerry);
finish();
break;
case R.id.bCallTanner:
startActivity(callOffice);
finish();
break;
case R.id.bEmailTanner:
Intent emailTanner = new Intent(Intent.ACTION_SEND);
emailTanner.putExtra(Intent.EXTRA_EMAIL,
new String[] { "thughes@smart-technologies.com" });
emailTanner
.putExtra(Intent.EXTRA_TEXT,
"This Email was sent by the Smart Technologies Android Application");
emailTanner.setType("text/plain");
startActivity(emailTanner);
finish();
break;
}
}
}
答案 0 :(得分:0)
多个scrollviews的问题是只有一个是可聚焦的。 我曾经创建了一个包含多个滚动视图的应用程序
并且在按钮上我改变了视图的可见性和可聚焦性,如此
public void buttonShowRankingClicked(final View v){
rankingScrollView.setVisibility(View.VISIBLE);
rankingScrollView.setFocusable(true);
rankingScrollView.setClickable(true);
teaminfoScrollView.setVisibility(View.GONE);
teaminfoScrollView.setFocusable(false);
teaminfoScrollView.setClickable(false);
}
这样,其他ScrollView将变为可见,您可以滚动:)