在Android布局文件中使用<include>时,我无法覆盖属性.当我搜索错误时,我发现了拒绝问题2863:
"包括标签被破坏(覆盖布局参数永远不会起作用)"
由于Romain表明这在测试套件及其示例中有效,因此我必须做错事.
我的项目组织如下:
res/layout
buttons.xml
res/layout-land
receipt.xml
res/layout-port
receipt.xml
Run Code Online (Sandbox Code Playgroud)
buttons.xml包含如下内容:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button .../>
<Button .../>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
肖像和横向的receipt.xml文件看起来像:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
...
<!-- Overridden attributes never work. Nor do attributes like
the red background, which is specified here. -->
<include
android:id="@+id/buttons_override"
android:background="#ff0000"
android:layout_width="fill_parent"
layout="@layout/buttons"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我错过了什么?
我有一个UI,根布局是RelativeLayout.它有许多视图,如字段,按钮等.
还有另外两个最初看不见的面板.当用户单击按钮时,其中一个面板从左侧滑入,另一个从底部滑入.问题是帧速率在Nexus S上是可悲的.
我想使用setDrawingCacheEnabled(true)以便(我希望)加速这两个面板的动画.作为一个简化的例子,这里大致是我在其中一个面板中滑动的方式.我称之为"detailPanel".
public class MyActivity extends Activity {
// Initially invisible.
private View detailPanel;
// A simple slide animation.
private Animation detailEnterAnimation;
...
public void someButtonClicked(View view) {
detailPanel.startAnimation(detailEnterAnimation);
detailPanel.setVisibility(View.VISIBLE);
detailPanel.setDrawingCacheEnabled(true);
}
}
Run Code Online (Sandbox Code Playgroud)
现在在DetailPanel中我尝试使用缓存.我希望通过缓存进行位图渲染可以提高性能:
public class DetailPanel extends LinearLayout {
public void draw(Canvas canvas) {
Bitmap cache = getDrawingCache();
if (cache != null) {
canvas.drawBitmap(cache, 0, 0, null);
} else {
super.draw(canvas);
}
}
}
Run Code Online (Sandbox Code Playgroud)
位图非空,大小合适,但它完全是黑色的.
为什么我的位图是黑色的?该代码可能是错误的; 我已经尝试了一百万种不同的东西而且无法弄明白.
我有一个带有OnClickListener的Button.为了便于说明,请考虑一个显示模态对话框的按钮:
public class SomeActivity ... {
protected void onCreate(Bundle state) {
super.onCreate(state);
findViewById(R.id.ok_button).setOnClickListener(
new View.OnClickListener() {
public void onClick(View v) {
// This should block input
new AlertDialog.Builder(SomeActivity.this)
.setCancelable(true)
.show();
}
});
}
Run Code Online (Sandbox Code Playgroud)
在正常使用情况下,会出现警告对话框并阻止进一步输入.用户必须先关闭对话框才能再次点击该按钮.
但有时在对话框出现之前,按钮的OnClickListener会被调用两次.您可以通过快速点击按钮轻松复制此内容.我通常必须在它发生之前尝试几次,但迟早我会在对话框阻止输入之前触发多次onClick(...)调用.
我在Motorola Droid手机的Android 2.1中看到了这种行为.我们在市场上收到了4份崩溃报告,表明这种情况偶尔发生在人们面前.
这取决于我们的OnClickListeners所做的事情,这会导致各种各样的破坏.我们怎样才能保证阻塞对话框在第一次点击后实际阻止输入?
我在家里使用MacBook,运行Leopard,安装了最新的Apple JDK 1.6.在IDE中,我想浏览com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel的源代码,但IDE无法找到它.我想浏览的另一个例子是com.sun.java.swing.plaf.nimbus.ButtonPainter.
为了浏览com.sun,我需要将哪些JAR或ZIP添加到我的IDEA项目中..雨云.IDE中的类我只对Leopard感兴趣,因为在Windows上使用Sun的JDk可以正常工作.
我知道Nimbus课程是可用的,因为我的应用程序运行Nimbus外观和感觉.