如何创建ArrayList带整数和字符串输入类型?如果我创建一个:
List<Integer> sections = new ArrayList <Integer>();
Run Code Online (Sandbox Code Playgroud)
这将是一种Integer类型ArrayList.如果我创建一个:
List<String> sections = new ArrayList <String>();
Run Code Online (Sandbox Code Playgroud)
这将是String类型.如何创建一个ArrayList可以采用整数和字符串输入类型的?谢谢.
我想声明一个ArrayList类型int.
为什么以下给我一个错误:
ArrayList<int> list1 = new ArrayList<int>();
Run Code Online (Sandbox Code Playgroud)
但以下工作:
ArrayList<Integer> list1 = new ArrayList<Integer>();
Run Code Online (Sandbox Code Playgroud)
?
我正在用Java编写一个简单的编辑文本.当用户打开它时,将打开一个文件JTabbedPane.我做了以下保存打开的文件:
HashMap<String, Tab> hash = new HashMap<String, Tab>();
哪里Tab会收到价值,例如:File file, JTextArea container, JTabbedPane tab.
我有一个叫做的课Tab:
public Tab(File file, JTextArea container, JTabbedPane tab)
{
this.file = file;
this.container = container;
this.tab = tab;
tab.add(file.getName(), container);
readFile();
}
Run Code Online (Sandbox Code Playgroud)
现在,在这个SaveFile类中,我需要获取Tab存储在中的值HashMap.我怎样才能做到这一点?
您是否使用assert关键字或抛出一些验证运行时异常?它给你带来了什么好处,或者为什么你觉得它不值得使用?
我对Android中的两种方法感到困惑.似乎这两种方法都告诉你它是什么类型的事件,即它是一个向下或向上的事件.
我什么时候用哪个?
public void onTouchEvent(MotionEvent e)
Run Code Online (Sandbox Code Playgroud)
请不要引用文档,因为我读了它,并且我没有看到任何参数可以提供给任何一种方法来获得不同的东西.
public final int getAction ()
Run Code Online (Sandbox Code Playgroud)
和
public final int getActionMasked()
Run Code Online (Sandbox Code Playgroud) 我正在尝试实现我在网上找到的一些源代码,使用Perlin Noise生成高度图.我已成功设法使用noise3函数获取高度图,第三个坐标是随机"种子",以允许随机高度贴图.
我的问题是产生的地形相当沉闷 - 我想要山脉,我正在滚动草原.我已经完成了对Perlin Noise的阅读(主要是在这里).由于源代码我发现显然没有考虑到可读性和我对Perlin Noise概念的一般掌握,我无法弄清楚我需要在代码中调整什么(幅度和频率?)到创造更加激烈的地形.
有关使用Perlin Noise,Perlin Noise,甚至更多可解码代码生成高度贴图的更多信息也将受到欢迎.
编辑:我理解(有点)Perlin Noise的工作原理,例如关于振幅和频率,我只是想知道在上面链接的代码中要改变哪些变量,这些变量用于这两个方面.
Android中是否有任何方法可以在运行时获取Android设备的虚拟键盘的高度.其实我想在键盘上方显示文本框.
我想为runnable使用匿名类.有两种方法,但我不知道他们是否做同样的事情:
方法一:直接使用Runnable和call run
new Runnable() {
@Override
public void run() {
}
}.run();
Run Code Online (Sandbox Code Playgroud)
方法二:创建一个匿名的runnable,并使用start方法而不是run来粘贴到Thread:
new Thread(new Runnable() {
@Override
public void run() {
}
}).start();
Run Code Online (Sandbox Code Playgroud)
我认为方法二显然是正确的.但是,我不知道它是否与方法一相同?我们可以Runnable直接在Runnable上调用方法吗?
谢谢 :)
在我的Android项目中,我不得不将TextChangedListener(TextWatcher)添加到编辑文本视图中.它有三个部分.
onTextChanged() beforeTextChanged() afterTextChanged()这三者的不同之处是什么?我不得不在关键的lisner上实现一个表的搜索,对于我的情况,这三个看起来都是一样的.他们也运作相同.当我输入产品名称的一部分时,表格会重新绘制,只包含那些包含输入文本的产品.但是我使用了这个afterTextChanged()部分.我的代码是
EditProduct.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before,
int count) {
// TODO Auto-generated method stub
// System.out.println("onTextChanged"+s);
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
// TODO Auto-generated method stub
// System.out.println("beforeTextChanged"+s);
}
@Override
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
// System.out.println("afterTextChanged"+s);
String new_prx = s.toString();
System.out.println(s);
mini_productList = new ArrayList<Product>();
// mini_productList
int count = 0; …Run Code Online (Sandbox Code Playgroud) 在布局XML文件中,红色感叹号显示在@drawable引用的左侧.几乎所有人drawable都有这个标志:
内容shape_detail_btn_border.xml如下.它是一组形状,没有任何损坏的图像资源:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@android:color/white"/>
<corners android:radius="5dp"/>
<stroke android:width="1dp" android:color="@color/bapul_color_d5d5d5"/>
</shape>
Run Code Online (Sandbox Code Playgroud)
我将鼠标悬停在标记上,没有显示任何内容.这是什么意思?
请注意,Android Studio版本为1.4(AI-141.2288178),目前是最新版本.并且,构建和运行应用程序完全没有问题.
java ×5
android ×4
arraylist ×2
assert ×1
exception ×1
hashmap ×1
integer ×1
motionevent ×1
perlin-noise ×1
runnable ×1
sdk ×1
terrain ×1
textwatcher ×1
touch ×1
validation ×1
xml ×1