小编Guy*_*kes的帖子

如何将变量放入字符串资源?

是否可以将变量放在字符串资源中?如果是的话 - 我如何使用它们.

我需要的是以下内容:

<string name="next_x_results">Next %X results</string>

并用int代替%X.

java android

58
推荐指数
3
解决办法
5万
查看次数

Android RelativeLayout更改颜色onClick

如何更改相对布局的颜色我用作可点击点击像普通按钮?就像我想要一个视觉反馈一样,布局被按下了.

我尝试使用绑定到background属性的选择器,如下所示:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
   <item android:state_focused="true" android:color="@android:color/black"/>
   <item android:state_pressed="true" android:state_enabled="false" android:color="@android:color/black" />
   <item android:color="@android:color/white"/>
</selector>
Run Code Online (Sandbox Code Playgroud)

并在布局背景中使用它...

android:background="@color/layout_selector"

但这给了我一个膨胀例外......

有任何想法吗?

java android

24
推荐指数
2
解决办法
3万
查看次数

Android:无法实例化应用程序

我重命名了我的包,现在我得到了这个奇怪的错误:

Unable to instantiate application
app.MyApplication: java.lang.ClassNotFoundException: 
app.MyApplication in loaderdalvik.system.PathClassLoader
Run Code Online (Sandbox Code Playgroud)

MyApplication班是Application/app.清单说:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  package="Application">
Run Code Online (Sandbox Code Playgroud)
<application 
    android:label="AGG"
    android:name="app.MyApplication"...
Run Code Online (Sandbox Code Playgroud)

我试过重新启动,清理内置.是在模拟器上还是在真实设备上不起作用.

地球上到底是怎么回事?

java android intellij-idea

20
推荐指数
3
解决办法
4万
查看次数

Android - 获取地图叠加项目的点击事件

我有一个带有Overlays的MapView,如下所示:

public class MyMapActivity extends MapActivity
{
    private MapItemizedOverlay itemizedOverlay;

    @Override
    public void onCreate(Bundle savedInstanceState)
    {
    for(a loop to put all 10 datas into overlay)
    {
    OverlayItem overlayitem=new OverlayItem(some params);
    overlayitem.setMarker(some bitmap);
    itemizedOverlay.addOverlay(overlayitem);
}
mapView.getOverlays().add(itemizedOverlay);
}
}

public class MapItemizedOverlay extends ItemizedOverlay<OverlayItem>
{

  //some code

@Override
protected boolean onTap(int index)
{
//Here I know what marker been clicked...
}
}
Run Code Online (Sandbox Code Playgroud)

我知道我在MapItemizedOverlay类中得到了什么标记.但是我如何在MapView中使用它?我想要的是在点击OverlayItem时显示气球提示,如此处在MapView中显示地图标记上方的弹出窗口.

请指导我,我根本不知道该怎么做......

非常感谢.

java android

6
推荐指数
1
解决办法
7275
查看次数

Android自定义ListViewItem布局

我不完全得到我的列表视图项目的布局不显示我想要它.我希望somone会给我一些提示,因为我现在已经有一段时间无法工作了.我想要的是如下:

在此输入图像描述

这是我的方法:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="20dip"
android:padding="6dip">
<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="3dip">
        <TextView
            android:id="@+id/nametext"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
        />
</LinearLayout>
<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="7dip">
        <ImageView
            android:id="@+id/photo"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:layout_marginRight="6dip"
            android:src="@drawable/icon" />
        <LinearLayout
            android:orientation="vertical"
            android:layout_width="0dip"
            android:layout_weight="1"
            android:layout_height="fill_parent">
            <TextView
                android:id="@+id/toptext"
                android:layout_width="fill_parent"
                android:layout_height="0dip"
                android:layout_weight="1"
                android:gravity="center_vertical"
            />
            <TextView
                android:layout_width="fill_parent"
                android:layout_height="0dip"
                android:layout_weight="1"
                android:id="@+id/middletext"
                android:singleLine="true"
                android:ellipsize="marquee"
            />
            <TextView
                android:layout_width="fill_parent"
                android:layout_height="0dip"
                android:layout_weight="1"
                android:id="@+id/bottomtext"
                android:singleLine="true"
                android:ellipsize="marquee"
            />
        </LinearLayout>
        <ImageView
            android:id="@+id/stars"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:layout_marginLeft="6dip"
            android:src="@drawable/icon" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

任何帮助,将不胜感激.我已经尝试过不同的尺寸和RelativeLayout.没变.它看起来并不像我认为的那样.

编辑三个缺失的空白

edit2添加了图片

java xml android intellij-idea

2
推荐指数
1
解决办法
1993
查看次数

Android完全隐藏RelativeLayout

我想完全隐藏相对布局.我有一个视图与几个布局我用作按钮与onClickListener.现在我想只显示我想要的那些按钮,因为有时候一个对象没有所有数据.我试图将visiblity设置为"4",它应该"消失"但是没有做到这一点.还有为此布局保留的空间.我该怎么办?

谢谢.

java android

1
推荐指数
2
解决办法
6062
查看次数

标签 统计

android ×6

java ×6

intellij-idea ×2

xml ×1