小编ver*_*one的帖子

如何改变搜索栏中拇指的颜色?

我的seekbarAndroid应用程序中有默认值.我注意到,当thumbseekbar举行,它变成黄色.相反,我希望它在持有时变成蓝色.如何才能做到这一点?如果这是一个基本问题我很抱歉,我是android开发的新手.谢谢.

xml android seekbar

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

如何在Notepad ++中使用退格转义序列?

我需要\n.txt文件中使用find new lines()并用backspace(\b)替换它们.在Notepad ++的查找和替换功能中使用它成功找到新行(\n),但用字符"\ b"替换它们而不是应用退格.怎么能正确完成?

string escaping notepad++

13
推荐指数
1
解决办法
4万
查看次数

如何将渐变设置为TextView的文本颜色?

textgradient.xml我的drawable文件夹中有一个包含gradient()的文件.我需要将此渐变作为TextView通过Java 的文本颜色.怎么做?

java android gradient

8
推荐指数
1
解决办法
3万
查看次数

Android:点击时列表中的项目不会变为橙色?

ListView我的应用程序代码中有一个,点击时使用一个AdapterView.OnItemClickListener来检测点击次数.问题是,当我点击某个项目时,该项目的背景变为白色,而不是默认的橙色.像这样:在此输入图像描述

另外,当我不使用AdapterView时,点击的项目会变成橙色而没有任何问题.如何使点击的项目的背景再次变为橙色?

编辑:

列表布局:main.xml

    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity" 
    android:background="#00000000">


        <!-- ListView (grid_items) -->

        <ListView android:id="@+id/listview"
            android:layout_height="fill_parent"
            android:textSize="15px"
            android:layout_width="fill_parent"
            android:background="#00000000">
        </ListView>

</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

的onCreate():

public void onCreate(Bundle savedInstanceState) {try{
    super.onCreate(savedInstanceState);


    setContentView(R.layout.main);
    lv= (ListView)findViewById(R.id.listview);
    lv.setBackgroundColor(Color.TRANSPARENT);
    lv.setCacheColorHint(Color.TRANSPARENT);
    //......calculations
    for(int q = 0; q <v; q++){
        HashMap<String, String> map = new HashMap<String, String>();
        map.put("col_1", array[q]);
        fillMaps.add(map);
        lv.setOnItemClickListener(onListClick);
    }
    //......calculations
    }
Run Code Online (Sandbox Code Playgroud)

适配器视图:

private AdapterView.OnItemClickListener onListClick=new AdapterView.OnItemClickListener(){

public void onItemClick(AdapterView<?> parent,View view, int position, long id)
{

lv.setBackgroundColor(Color.TRANSPARENT); …
Run Code Online (Sandbox Code Playgroud)

java android listview android-adapter

5
推荐指数
1
解决办法
1200
查看次数

ImageView没有拉伸(Android)?

我在RelativeLayout中有一个ImageView.ImageView的源是一个.png文件.问题是,在具有不同分辨率的设备上测试时,android不会向上或向下缩放图像.我在android文档中读到android自动向上或向下缩放图像以填充屏幕,但这不会发生.可能是什么问题呢?我是android的新手,抱歉,如果这个问题很愚蠢,我搜索了很多,但找不到解决方案.

编辑:XML:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
     >

<ImageView
        android:id="@+id/imageview1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"

        android:layout_centerInParent="true"
        android:clickable="false"
        android:scaleType="fitXY"
        android:contentDescription="@string/p"

        android:src="@drawable/example" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

编辑2:我需要拉伸的XML布局:

    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:theme="@android:style/Theme.Black.NoTitleBar" 
    android:gravity="center">

    <ImageView
        android:id="@+id/imageView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/imageView1"
        android:clickable="false"

        android:contentDescription="@string/p"

        android:src="@drawable/volbar" />



    <ImageView

        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:clickable="false"
        android:layout_alignParentLeft="true"
        android:contentDescription="@string/p"

        android:src="@drawable/head" />

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/imageView1"
        android:layout_alignParentLeft="true"
        android:layout_marginBottom="33dp"
        android:layout_marginRight="19dp"
        android:text="@string/press_to_update" />

    <ImageView
        android:id="@+id/imageView9"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/imageView2"
        android:clickable="false"
              android:contentDescription="@string/p"

        android:src="@drawable/frag11"
         />

    <ImageView
        android:id="@+id/imageView4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"

        android:layout_below="@+id/imageView9"
        android:clickable="false"
        android:contentDescription="@string/p" …
Run Code Online (Sandbox Code Playgroud)

xml android relativelayout imageview

4
推荐指数
1
解决办法
8552
查看次数

在 android MediaPlayer 中开始在状态 4 错误中调用?

我正在开始播放服务中的在线音频流。这是开始播放的方法:

    void start1(String a){
        try{
        mp.setDataSource(a);//mp is a global MediaPlayer variable
        mp.setOnPreparedListener(this);
        mp.prepareAsync();
        mp.start();
        }catch(Exception e){
            noerror=false;
                }
  }
Run Code Online (Sandbox Code Playgroud)

onPrepared()函数:

    @Override
  public void onPrepared(MediaPlayer mp1){
        mp.start();
    }
Run Code Online (Sandbox Code Playgroud)

这段代码给了我错误

Start called in state 4: error(-38,0)
Run Code Online (Sandbox Code Playgroud)

这段代码有什么问题?

java android android-mediaplayer

3
推荐指数
1
解决办法
4596
查看次数

如何在android中启动设备启动服务?

我正在创建一个应用程序,它需要一直运行的服务,即使应用程序关闭,从设备启动到设备关闭.这可以在android中完成吗?

java android android-launcher

3
推荐指数
1
解决办法
3421
查看次数

如何使用FileOutputStream删除.txt文件中的行?

我需要从.txt存储在android设备内部存储器中的文件中删除一行.我在用

FileOutputStream fos = context.openFileOutput("file.txt", Context.MODE_APPEND);

打开.txt文件.我已经知道要删除的行.如何删除它?很抱歉,如果这个问题很简单,我看上去并且无法在Google上找到答案.

java android fileoutputstream

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

图像需要太长时间才能加载布局?

ImageView用来制作一个1.3 MB的图像作为活动的背景.活动有另一个较小的图像(徽标)和3个按钮.那项活动没有别的.现在此活动最多需要9秒才能显示.直到那时应用程序显示黑屏.当我使用1.3 MB图像删除ImageView时,活动立即加载.因此,ImageView加载图像需要这么长时间才是正常的吗?我怎样才能减少这个时间?

xml android imageview android-imageview

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