如何在按钮中嵌入标签布局。我的主要布局是线性布局,但我不知道如何编写主要的activity.java类。任何人都可以帮我开始这是我的main.java代码现在的样子
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.content.Intent;
public class Remote_DocActivity extends Activity implements OnClickListener {
/** Called when the activity is first created. */
//private static final String TAG = "Remote_Doc";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
View Patient_Button = findViewById(R.id.patientButton);
Patient_Button.setOnClickListener(this);
View Doctor_Button = findViewById(R.id.doctorButton);
Doctor_Button.setOnClickListener(this);
View About_Option = findViewById(R.id.aboutButton);
About_Option.setOnClickListener(this);
View Exit_Option = findViewById(R.id.exit);
Exit_Option.setOnClickListener(this);
}
public void onClick(View v) {
switch (v.getId()) {
case R.id.aboutButton:
Intent i = new Intent(this, About.class);
startActivity(i);
break;
case R.id.exit:
finish();
break;
}
}
}
答案 0 :(得分:1)
您可以在TabActivity类的帮助下创建标签。您可以从android-wireless-application-development book的第3章第8章示例中获取帮助。