小编kai*_*uki的帖子

getItemAtPosition()不返回listview中的值

我创建了一个自定义Base Adapter类,用图像和文本填充列表视图.课程代码如下:

public class ViewAdapter extends BaseAdapter {

private Activity activity;
private String[] data;
private static LayoutInflater inflater=null;
public ImageLoader imageLoader; 
private ArrayList<String> items;

public ViewAdapter(Activity a, ArrayList<String> items,String[] d) {
    this.items = items;     
    activity = a;
    data=d;
    inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    imageLoader=new ImageLoader(activity.getApplicationContext());
}

public int getCount() {
    return data.length;
}

public Object getItem(int position) {
    return position;
}

public long getItemId(int position) {
    return position;
}

public static class ViewHolder{
    public TextView text;
    public ImageView image;
}

public View …
Run Code Online (Sandbox Code Playgroud)

android listview adapter

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

如何检查URL是否在webview中加载

我正在使用下面的代码在android webview中加载url

webviewShowPost.loadUrl(URL);
Run Code Online (Sandbox Code Playgroud)

我想检查是否没有可用的数据连接,然后webview而不是显示空白视图,我可以显示没有连接的Toast.

谢谢

url android connectivity webview

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

如何在JAVA中以"dd-MM-yyyy"格式转换字符串"2011-11-29 12:34:25"

我正在尝试转换字符串中的日期,并将格式为"yyyy-MM-dd HH:mm:ss"改为"dd-MM-yyyy".

我已经实现了以下代码,但它给出了:java.lang.IllegalArgumentException

        SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
        Date date = new Date(values);
        String mydate = dateFormat.format(date);
Run Code Online (Sandbox Code Playgroud)

java string format date

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

如何将图像视图附加为电子邮件附件?

我在图像视图上生成饼图,我想通过电子邮件发送它.

如何将图像视图的图像转换为电子邮件附件,因为它在资源中不可用?

android email-attachments imageview

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

Android更改日期选择器底部按钮栏的颜色

我正在尝试更改日期选择器的颜色,我得到的结果是这样的

日期选择器

底部按钮栏为白色,隐藏了按钮文本,因为它们也是白色的。我想将按钮栏更改为黑色,但即使添加样式并将buttonBarStyle背景设置为黑色也无济于事。我的xml粘贴在下面

<style name="DatePickerTheme_Dark" parent="Theme.AppCompat.Dialog">
    <item name="colorAccent">@color/highlight_color_blue</item>
    <item name="android:datePickerStyle">@style/MyDatePickerStyleDark</item>
    <item name="buttonBarStyle">@style/mybuttonbar</item>    
</style>

<style name="mybuttonbar" parent="Widget.AppCompat.ButtonBar.AlertDialog">
    <item name="android:background">@color/background_color_black</item>
</style>

<style name="MyDatePickerStyleDark" parent="@android:style/Widget.Material.DatePicker">
    <item name="android:headerBackground">@color/highlight_color_blue</item>
    <item name="android:background">@color/background_color_black</item>
</style>
Run Code Online (Sandbox Code Playgroud)

我现在要做的就是将底部按钮栏样式/颜色设置为黑色。

我还尝试将底部按钮的文本更改为黑色,但日期选择器在底部栏中的白色下看起来很尴尬。这就是为什么更喜欢将整个底栏颜色更改为黑色。

android themes styles datepicker material-design

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

取出那些没有分配给员工的部门

我想写一个sql查询,并希望从DEPT表中获取没有在EMP表中分配员工的dept名称.

表结构:

EMP
EMPNO   ENAME    DEPTNO

DEPT
DEPTNO   DNAME
Run Code Online (Sandbox Code Playgroud)

所以我想知道那些没有员工协会的DEPT.

sql select

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

如何在Android中删除对话框的标题

可能重复:
Android:如何创建没有标题的Dialog?

我如何从Android中的对话框中删除标题标题,该标题为灰色.

android dialog header

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

使用Facebook android SDK发布到Facebook特定的朋友列表

我成功发布到Facebook墙,但我希望用户可以选择是否要将其发布到某些特定的朋友列表,例如熟人,家庭等

我的代码给出了这个错误:

{"error":{"message":"(#100) privacy must contains a valid privacy 'value'","type":"OAuthException"}}
Run Code Online (Sandbox Code Playgroud)

我添加了"隐私"属性并赋予它"家庭"的价值,但它不起作用,但是如果我删除了隐私属性,那么墙贴就成功了

try
        {
            Bundle parameters = new Bundle();
            parameters.putString("message", msg);
            parameters.putString("description", "Test 1");
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("value", "Family");
            parameters.putString("privacy", jsonObject.toString());
            response = Data.facebook.request("me/feed", parameters,"POST");

        } catch(Exception e) {
            e.printStackTrace();
        }
Run Code Online (Sandbox Code Playgroud)

android privacy posting facebook-graph-api

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

标签主机不显示标签

我正在使用标签主机来显示标签,但即使我只是将其拖放到我的布局上并运行它,它没有显示标签,它显示白色屏幕,我猜这是第一个标签视图的线性布局.

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

    <TabHost
        android:id="@android:id/tabhost"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical" >

            <TabWidget
                android:id="@android:id/tabs"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" >
            </TabWidget>

            <FrameLayout
                android:id="@android:id/tabcontent"
                android:layout_width="match_parent"
                android:layout_height="match_parent" >

                <LinearLayout
                    android:id="@+id/tab1"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" >
                </LinearLayout>

                <LinearLayout
                    android:id="@+id/tab2"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" >
                </LinearLayout>

                <LinearLayout
                    android:id="@+id/tab3"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" >
                </LinearLayout>
            </FrameLayout>
        </LinearLayout>
    </TabHost>

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

当我在模拟器或手机(华为Ascend P1)上面运行时,没有显示任何标签.

屏幕截图

tabs android android-tabhost

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

来自Application类的Android Marshmallow permisions

我正在整合第三方sdk,它是从应用程序类启动的.但是在Android Marshmallow API 23上进行测试时,我收到权限错误,因为SDK需要"ACCESS_COARSE_LOCATION"权限.

因为我需要在应用程序级别上集成SDK,而不是在活动级别上,当我打电话时

 ActivityCompat.requestPermissions(this,new String[]{Manifest.permission.ACCESS_FINE_LOCATION},1 );
Run Code Online (Sandbox Code Playgroud)

IDE正在给出错误,因为"this"不是Activity.

是否可以从Application类请求Android权限.

permissions android request android-6.0-marshmallow

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