所以我有一个活动,我希望它全屏显示,显示标题栏和系统按钮(后退,最小化......)。我确实从developers.android.com获取了一段代码,它确实会全屏显示,但是当我按下屏幕时,标题会弹出,按钮也会出现,我希望它仅在我向上/向下滑动手指时才弹出在我的屏幕的顶部/底部。
我的活动如下所示:
package com.example.nsomething.main;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import com.example.nsomething.R;
public class Report extends Activity {
@TargetApi(Build.VERSION_CODES.KITKAT)
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
setContentView(R.layout.report);
initialize();
}
private void initialize() {
Button report = (Button) findViewById(R.id.button1);
report.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
startActivity(new Intent(Report.this, Harta.class));
finish();
}
});
}
}
Run Code Online (Sandbox Code Playgroud) 所以我有三个按钮,比方说1,2和3.我想,当我点击button1时,取消选择button2和button3.之后,当我点击button2时,我想要取消选择button1和button3.button3也是如此.
基本上,当我单击一个按钮时,我希望取消选择其他2个按钮.到目前为止,我有以下代码,但我被困在某处,我看不出错误.
if(smallbuttonpage1.isSelected()){
normalbuttonpage1.setSelected(false);
bigbuttonpage1.setSelected(false);
textpage1.setFont(new Font("ComicSansMS", Font.PLAIN, 8));
}
if(normalbuttonpage1.isSelected()){
smallbuttonpage1.setSelected(false);
bigbuttonpage1.setSelected(false);
textpage1.setFont(new Font("ComicSansMS", Font.PLAIN, 12));
}
if(bigbuttonpage1.isSelected()){
smallbuttonpage1.setSelected(false);
normalbuttonpage1.setSelected(false);
textpage1.setFont(new Font("ComicSansMS", Font.PLAIN, 20));
}
Run Code Online (Sandbox Code Playgroud) 我正在学习Java,到目前为止我已经达到了Vector
s,但我的IDE似乎给了我一些问题,所以我想问你一个可能解决我的问题的方法.
import java.util.*;
public class Vector {
public static void main(String args[]) {
// initial size is 3, increment is 2
Vector v = new Vector(3, 2);
System.out.println("Initial size: " + v.size());
System.out.println("Initial capacity: " + v.capacity());
v.addElement(new Integer(1));
v.addElement(new Integer(2));
v.addElement(new Integer(3));
v.addElement(new Integer(4));
System.out.println("Capacity after four additions: " + v.capacity());
v.addElement(new Double(5.45));
System.out.println("Current capacity: " + v.capacity());
v.addElement(new Double(6.08));
v.addElement(new Integer(7));
System.out.println("Current capacity: " + v.capacity());
v.addElement(new Float(9.4));
v.addElement(new Integer(10));
System.out.println("Current capacity: " + v.capacity());
v.addElement(new …
Run Code Online (Sandbox Code Playgroud) 所以我有一个700x700的屏幕,我想创建一个物体(一个小行星)从屏幕左侧移动到右侧.一旦它离开屏幕,我希望它随机产生Y ana做同样的事情.到目前为止,我创建的对象以随机Y生成并向右移动,但是,在0:100像素和600:700像素之间,我有对象,我不希望我的对象产生并穿过这些对象.我希望随机Y介于101和599之间.
if (centerX > width + 200) {
isTravelling = false;
centerX = -200;
centerY = (int)(Math.random());
}
Run Code Online (Sandbox Code Playgroud)