我尝试以编程方式设置背景颜色,但是当我设置每种颜色时,背景为黑色,但任何颜色背景都是白色,就像应用程序主题一样.
View someView = findViewById(R.id.screen);
View root = someView.getRootView();
root.setBackgroundColor(color.white);
Run Code Online (Sandbox Code Playgroud)
你能看到代码吗?
因此,每当我尝试在Android模拟器上启动我的应用程序时,IDE都会受到此错误的轰炸:
Emulator: qemu-system-i386.exe: goldfish_battery_read: Bad offset.......
Run Code Online (Sandbox Code Playgroud)
每隔一分钟左右运行应用程序时,此错误也会显示.
我正在使用
...
我已经尝试重新安装所有SDK工具并将所有内容更新到最新但没有运气.我还重新安装了IDE并重新下载了所有内容,它仍然显示此错误.
我想知道是否还有人遇到这个错误?
来自Brian W. Kernighan的C编程语言
&运算符仅适用于内存中的对象:变量和数组元素.它不能应用于表达式,常量或寄存器变量.
如果不在内存中,表达式和常量存储在哪里?这句话是什么意思?
例如:
&(2 + 3)
为什么我们不能拿它的地址?它存放在哪里?
对于C++,答案是否也一样,因为C一直是它的父级?
这个链接的问题解释了这样的表达式是rvalue
对象,并且所有rvalue
对象都没有地址.
我的问题是这些表达式存储在哪里,以至于无法检索到它们的地址?
如何设置setLayoutParams()
的LinearLayout
元素.在MainActivity.java
.我为set layout params编写了以下代码,并nullPointerException
在第50行显示,最后我粘贴了Logcat文件.
layoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, 50);
imageview1.setLayoutParams(layoutParams); // line no 50
layoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, 50);
textview1.setLayoutParams(layoutParams);
layoutParams = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT);
listview01.setLayoutParams(layoutParams);
Run Code Online (Sandbox Code Playgroud)
这是我的xml文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:stackFromBottom="true"
>
<ImageView
android:id="@+id/imageview1"
android:layout_width="wrap_content"
android:layout_height="50px"
android:background="@drawable/applicationbar"
android:layout_x="0px"
android:layout_y="0px"
>
</ImageView>
<TextView
android:id="@+id/textview1"
android:layout_width="wrap_content"
android:layout_height="50px"
android:text="TextView"
android:layout_x="0px"
android:layout_y="55px"
>
</TextView>
<ListView android:id="@+id/ListView01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10px"
android:layout_marginRight="10px"
android:layout_marginTop="35px"
android:layout_marginBottom="40px"
android:paddingLeft="0px"
android:paddingRight="0px" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
原木猫:
04-19 16:47:22.221: ERROR/AndroidRuntime(3437): Uncaught handler: thread …
Run Code Online (Sandbox Code Playgroud) 你好我试图在我的列表视图中长按一个项目时弹出一个小菜单可以有人指出我正确的方向来完成这个吗?
我创建了一个EditText
for搜索,它在左侧包含一个搜索图标,在图标的右侧:
<EditText
android:id="@+id/Search"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:drawableLeft="@android:drawable/ic_menu_search"
android:drawableRight="@android:drawable/ic_delete"
android:hint="Search Product .." >
</EditText>
Run Code Online (Sandbox Code Playgroud)
我想知道如何清除EditText
单击十字按钮时的内容.
先感谢您.
我正在使用ScrollView,我想设置ScrollBar大小,但我尝试的一切都失败了.我尝试使用属性android:scrollbarSize,带有样式,主题但没有.滚动条的大小始终相同.有什么建议?谢谢
我试过这个:
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="10px"
android:layout_marginBottom="15px"
android:scrollbarSize="20px"
android:scrollbarTrackVertical="@drawable/scrollbar_reflection"
android:scrollbarThumbVertical="@drawable/scrollbar_state2">
Run Code Online (Sandbox Code Playgroud)
但滚动条的宽度不会改变.
所以我创建了一个这样的样式文件:
<resources>
<style name="ShowAllScrollBar1">
<item name="android:scrollbarSize">20px</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
然后在AndroidManifest中设置样式.
我使用以下代码来检测单指触摸和双指触摸.代码检测到双指触摸(何时count==2
).
我也需要在单点触控上做一些动作.如果我用一根手指触摸屏幕,它就不会用于其他部分.我在这段代码中做错了什么?
@Override
public boolean onTouchEvent(MotionEvent event) {
int action = event.getAction() & MotionEvent.ACTION_MASK;
switch (action) {
case MotionEvent.ACTION_POINTER_UP: {
int count = event.getPointerCount();
Log.v("count >>", count + "");
if (count == 2) {
// some action
} else {
Log.v("count not equal to 2", "not 2");
}
break;
}
}
return true;
}
Run Code Online (Sandbox Code Playgroud)
更新:
我在里面用了这个代码Activity
.我需要检测单点触控,多点触控.
在我的活动中,我有两个图像,一个在左边,一个在右边.如果我点击图像,一些过程必须要做.如果我用两根手指,我需要重新调整图像大小scale-factor
.
这是我用过的代码:
更新:
package com.pinch.detect;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import …
Run Code Online (Sandbox Code Playgroud) 在我的应用程序中,一些联系人被附加到单个.vcf文件并且该文件发送到邮件,尝试在log cat中显示所有联系人数据,但是无法发送附加到单个.vcf文件的所有数据?
任何人都有这个帮助我的想法,请.
这是我的代码
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
vCard = new ArrayList<String>();
Log.i("TAG one", "vfile" +vfile);
vfile = "Contacts" + "_" + System.currentTimeMillis() + ".vcf";
/**
* This Function For Vcard And here i take one Array List in Which i
* store every Vcard String of Every Contact Here i take one Cursor and
* this cursor is not null and its count>0 than i repeat one loop up to
* cursor.getcount() means Up …
Run Code Online (Sandbox Code Playgroud) 我刚刚从稳定的频道将Android Studio更新到2016年4月5日的版本2.0,现在我尝试构建项目时出现了一个奇怪的错误:
忽略没有关联的EnclosingMethod属性的匿名内部类(org.apache.commons.collections.BeanMap $ 1)的InnerClasses属性.这个类可能是由一个没有以现代.class文件格式为目标的编译器生成的.建议的解决方案是使用最新的编译器从源代码重新编译类,而不指定任何"-target"类型选项.忽略此警告的后果是,对此类的反射操作将错误地指示它不是内部类.
这是我的依赖项:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'me.dm7.barcodescanner:zxing:1.7.2'
compile 'com.github.navasmdc:MaterialDesign:1.5@aar'
compile 'com.github.rey5137:material:1.1.1'
compile 'com.rengwuxian.materialedittext:library:2.1.4'
compile files('libs/java-json.jar')
compile 'com.google.code.gson:gson:2.4'
compile 'se.emilsjolander:stickylistheaders:2.7.0'
compile('com.thoughtworks.xstream:xstream:1.4.7') {
exclude group: 'xmlpull', module: 'xmlpull'
}
compile ('com.github.ganfra:material-spinner:1.1.0'){
exclude group: 'com.nineoldandroids', module: 'library'
exclude group: 'com.android.support', module: 'appcompat-v7'
}
compile 'ch.qos.logback:logback-core:1.1.7'
compile 'org.slf4j:slf4j-api:1.7.21'
}
Run Code Online (Sandbox Code Playgroud)
任何帮助将是欣赏.
android build android-studio build.gradle android-gradle-plugin