小编Eri*_*ric的帖子

什么是ImageView的默认比例类型?

我可以缩放图像的边界到的范围设置选项ImageView使用setScaleType(ImageView.ScaleType).

什么是默认值ImageView.ScaleType?

android imageview

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

API中的GridView填充少于10

我需要在Android API中没有填充的GridView小于10.我的布局:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
tools:context=".MainActivity" >

<GridView
    android:id="@+id/grid"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
    android:alwaysDrawnWithCache="true"
    android:background="@color/gridview_background"
    android:clipChildren="true"
    android:horizontalSpacing="1dp"
    android:numColumns="6"
    android:verticalSpacing="1dp" />
Run Code Online (Sandbox Code Playgroud)

结果:

在此输入图像描述

填充上显示红色箭头.它仅在Android <3.0中我需要的结果

在此输入图像描述

没有填充物.

PS完全相同的Android 3.0上的代码没有填充.这是为什么?

android gridview

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

Actionbar样式溢出菜单项

我需要制作完全自定义的溢出菜单项(不同的背景颜色,如图所示).

https://dl.dropbox.com/u/7771649/overflow.png

可能吗?

android themes android-actionbar

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

如何找到连接蓝牙设备的信号强度

在我的一个应用程序中,我需要显示与我的手机配对的所有wi-fi和蓝牙设备,以及它们的信号强度.有了wi-fi,我可以显示信号强度(RSSI).但我的蓝牙问题.我搜索了一些适合这项任务的方法; 我找到了一种方法:

intent.getShortExtra(BluetoothDevice.EXTRA_RSSI, Short.MIN_VALUE);
Run Code Online (Sandbox Code Playgroud)

但它只显示未与我的手机配对的新设备RSSI.是否有任何想法让所有蓝牙设备RSSI?

android bluetooth rssi

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

Twitter4j TwitterStream停止/关闭

我有一个Android应用程序启动TwitterStream与Twitter4j,我正在寻找帮助,如果我不再需要流停止/关闭它.我根据偏好更改启动了流,但需要根据用户操作在我的应用的其他部分停止它.

以下是我启动流的方式,这是我在文档中找到的典型方法:

ConfigurationBuilder cb = new ConfigurationBuilder();

cb.setDebugEnabled(true);

cb.setOAuthConsumerKey(A);

cb.setOAuthConsumerSecret(B);

cb.setOAuthAccessToken(C);

cb.setOAuthAccessTokenSecret(D));

TwitterStream twitterStream = new TwitterStreamFactory(cb.build()).getInstance();
StatusListener listener = new StatusListener() {

    @Override
    public void onDeletionNotice(StatusDeletionNotice arg0) {

    }
    .
    .   
    .

};
FilterQuery fq = new FilterQuery();
fq.follow(new long[]{X});

twitterStream.addListener(listener);
twitterStream.filter(fq); 
Run Code Online (Sandbox Code Playgroud)

任何帮助将不胜感激,谢谢!

twitter android twitter4j twitter-streaming-api

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

如何在OpenCV中从Mat对象m读取每个像素的值作为RGB值

这是我rectangle.jpg从中读取图像的代码/sdcard.我想知道像素值(正常,以及RGB格式).我应该使用什么代码来处理它?

package com.idag.edge;

import android.os.Bundle;
import android.os.Environment;
import android.app.Activity;
import android.util.Log;
import android.widget.TextView;

import org.opencv.android.OpenCVLoader;
import org.opencv.core.Mat;
import org.opencv.highgui.Highgui;

public class MainActivity extends Activity {  
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        try
        {
            String path=Environment.getExternalStorageDirectory().getAbsolutePath() +"/rectangle.jpg";
            Mat m=Highgui.imread(path,1); 
            Log.i("Paramenres on matrix", "height "+ m.height()+" width "+ m.width()+" total = "+m.total()+" channels " +m.channels());

            System.out.println("element at 0 0 = "+ m.row(0).col(0).nativeObj+" element at 150 150 = "+ m.row(150).col(150).nativeObj);
        }

        catch(Exception e){
            System.err.print("Error in the code"); …
Run Code Online (Sandbox Code Playgroud)

java android opencv

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

将List <String>放在Bundle中

我有一个IntentService连接到一个网站,并通过JSoup创建一个解析HTML的列表.我现在需要将该列表传回一个Bundle,我不知道该怎么做.这是我的代码IntentService:

public class NewerService extends IntentService {

public NewerService() {
    super("NewerService");
    // TODO Auto-generated constructor stub
}

@Override
protected void onHandleIntent(Intent intent) {
    ResultReceiver rec = intent.getParcelableExtra("receiverTag");
    String playersName = intent.getStringExtra("Player");
    List<String> list = new ArrayList<String>();
    Document doc = null;
    try {
        doc = Jsoup.connect("http://espn.go.com/nhl/team/stats/_/name/phi/philadelphia-flyers").get();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    for (Element table : doc.select("table.tablehead")) {
        for (Element row : table.select("tr")) {
            Elements tds = row.select("td");
            if …
Run Code Online (Sandbox Code Playgroud)

android bundle arraylist intentservice

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

将毫秒字符串转换为SimpleCursorAdapter中的格式化日期字符串

我正在String从我的SQLite数据库中检索一毫秒,并希望将其转换为格式化日期String.它基本上可以工作,但不是当我在一个数组中尝试它时(见下文).它扔了一个NumberFormatException.我怎样才能解决这个问题?

adapter = new SimpleCursorAdapter(this, R.layout.listrow, cursor,
        new String[] { getDate(Long.parseLong(Database.KEY_DATE), "dd. MMMM yyyy hh:mm:ss") , Database.KEY_NAME },
        new int[] {R.id.text1, R.id.text2}, 0);

public static String getDate(Long milliSeconds, String dateFormat){
SimpleDateFormat formatter = new SimpleDateFormat(dateFormat);
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(milliSeconds);
return formatter.format(calendar.getTime());
}
Run Code Online (Sandbox Code Playgroud)

android adapter

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

getExternalFilesDir(null)抛出NullPointerException

我正在构建一个Android应用程序,我选择在外部存储中使用平面苍蝇作为我的持久性方法.我有一个使用一些静态实例方法扩展Application的类.经过几次调试后,我注意到没有任何实例变量null,而且NullPointerException来自内部Context.getExternalFilesDir(null).

我想以任何答案为前言,不返回null.此外,我在清单中拥有正确的权限,以及检查SD卡是否已安装到设备上.

这是保存调用getExternalFilesDir(null)并抛出错误的类.

public class WhileImOut extends Application {

    public static TaskManager taskManager;
    private static Context appContext;

    public WhileImOut() {
        super();
        appContext = this;
        initialize();
    }

    public static void initialize() {
        if (taskManager == null && Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
            try{
            File f = appContext.getExternalFilesDir(null); // Exception being thrown here
            taskManager = new TaskManager(f.getAbsolutePath());
            }catch(NullPointerException e){
                Log.d("Bad","NPE");
            }catch(Exception e){

            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

这是在我的AndroidManifest.xml中:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Run Code Online (Sandbox Code Playgroud)

任何帮助将不胜感激.我已经在这几个小时内苦苦挣扎,我会接受任何建议.谢谢

编辑:LogCat信息

10-10 18:55:56.424: E/AndroidRuntime(964): FATAL EXCEPTION: …
Run Code Online (Sandbox Code Playgroud)

java android nullpointerexception

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

简单的PHP数据库连接

我正在制作一个简单的页面来测试数据库连接.当我尝试从浏览器访问它时,它说:

服务器错误

检索时网站遇到错误http://localhost:8888/blah/blah/test.php.它可能已关闭以进行维护或配置不正确.

以下是一些建议:

稍后重新载入此网页.HTTP错误500(内部服务器错误):服务器尝试完成请求时遇到意外情况.

我所做的就是连接数据库并显示表格.以下是我所拥有的PHP代码:

<?php
// Get Variables
$dbname = $_GET["dbname"];
$dbusername = $_GET["dbusername"];
$dbpass = $_GET["dbpass"];
$dbhost = $_GET["dbhost"];






$connection = mysql_connect("$dbhost","$dbusername","$dbpass");
if (!$connection)
{
    die('Could not connect: ' . mysql_error());
}
else
{
    echo "Connected";

    $dbcheck = mysql_select_db("$dbname");
    if (!$dbcheck) {
        echo mysql_error();
    }else{
        echo "<p>Successfully connected to the database '" . $database . "'</p>\n";
// Check tables
        $sql = "SHOW TABLES FROM `$database`";
        $result = mysql_query($sql);
        if (mysql_num_rows($result) > 0) {
            echo "<p>Available …
Run Code Online (Sandbox Code Playgroud)

php mysql database server-side web

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