小编Adi*_*han的帖子

如何制作轮子选择器

我试图让一个车轮选取器像这个 我已经试过下载此项目,但包含在.zip下载的文件只有轮demo.apk和notes.txt.Notes.txt没有关于如何在android studio中使用此文件的任何说明.我找到了一篇建议使用ListViews创建相同效果的帖子.而不是自己做我自己花了一天时间搜索互联网,我在这里找到了源代码,但当我将文件导入我的项目时,IDE显示了几十个错误.通过反复试验,我设法修复了除3个错误之外的所有错误.很确定我已将相关代码放在下面
MainActivity.java:

OnWheelScrollListener scrolledListener = new OnWheelScrollListener()
{
    public void onScrollingStarted(WheelView wheel)
    {
        wheelScrolled = true;// "Cannot resolve symbol wheelScrolled
    }

    public void onScrollingFinished(WheelView wheel)
    {
        wheelScrolled = false;// "Cannot resolve symbol wheelScrolled
        updateStatus();
    }
};

// Wheel changed listener
private final OnWheelChangedListener changedListener = new OnWheelChangedListener()
{
    public void onChanged(WheelView wheel, int oldValue, int newValue)
    {
        if (!wheelScrolled)// "Cannot resolve symbol wheelScrolled
        {
            updateStatus();
        }
    }
};
private void initWheel1(int id)
{ …
Run Code Online (Sandbox Code Playgroud)

android android-layout

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

动态更改Gridview列宽

我正在尝试更改我的GridView. 目前,项目在 xml 中按样式 (GridView_words_small) 排列:

numColumns: auto_fit
stetchMode: 'spacingWidth'
ColumnWidth: width of the items being added (resource). 
Run Code Online (Sandbox Code Playgroud)

现在,通过设置更改,可以更改按钮大小。但是,当 IsetColumnWidth()和时invalidate(),不会显示任何项目(将该区域留空。)

有谁知道如何gridview动态正确更改列宽?

android gridview android-layout

5
推荐指数
0
解决办法
2808
查看次数

如何在Android中的谷歌地图上显示波纹动画?

我正在尝试google map使用特定的Lat-Lng 设置涟漪动画,请看到完全描述了我想要的内容,我在上面提到链接但无法设置动画google map.

我到目前为止所尝试的是 -

我的xml代码:

<com.test.custom.RippleBackground
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/rippleLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:visibility="gone"
        app:rb_color="#0099CC"
        app:rb_duration="5000"        
        app:rb_radius="32dp"
        app:rb_rippleAmount="4"
        app:rb_scale="6" >

        <ImageView
            android:id="@+id/imgMapProfile"
            android:layout_width="64dp"
            android:layout_height="64dp"
            android:layout_centerInParent="true"
            android:src="@drawable/ic_profile_active" />
    </com.test.custom.RippleBackground>
Run Code Online (Sandbox Code Playgroud)

我的Java代码在谷歌地图上放置涟漪:

 LatLng currentAddressLatLong;              
                        currentAddressLatLong = new LatLng(gps.getLatitude(), gps.getLongitude());

                    RippleBackground rippleLayout=(RippleBackground)findViewById(R.id.rippleLayout);
                    rippleLayout.setVisibility(View.VISIBLE);
                    ImageView imgMapProfile=(ImageView)findViewById(R.id.imgMapProfile);

                    Bitmap markerUserBitmap = Comman.createDrawableFromView(NearByActivity.this, rippleLayout);
                    googleMap.addMarker(new MarkerOptions().position(currentAddressLatLong).icon(BitmapDescriptorFactory.fromBitmap(markerUserBitmap)));
                    googleMap.moveCamera(CameraUpdateFactory.newLatLng(currentAddressLatLong));
                    googleMap.animateCamera(CameraUpdateFactory.zoomTo(11));

                    rippleLayout.startRippleAnimation();

     // Convert a view to bitmap function
            public static Bitmap createDrawableFromView(Context context, View view) 
            {
                DisplayMetrics displayMetrics = new DisplayMetrics();
                ((Activity)context).getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
                view.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, …
Run Code Online (Sandbox Code Playgroud)

android google-maps

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

在列表视图中添加收藏夹按钮

我有一个listview每个列表项都有一个收藏夹按钮,点击后应该将列表项添加到另一个名为my fav9rites的活动中.我使用的是Baseadapter用于listviewSharedpreference添加收藏夹.当我单击收藏夹按钮时,列表视图项目将添加到我的收藏夹活动中,但我遇到以下问题:

1)单击时的收藏夹按钮应变暗,表示列表项已添加到收藏夹.发生这种情况但是当我关闭活动并再次返回时,按钮会恢复而不是变暗

2)在我的收藏夹活动中长按列表项目时,应从收藏夹中删除列表项,但这不会发生.

希望大家都明白我的问题

我的代码

我的基础适配器

public View getView(final int position, View view, ViewGroup parent)
{
    final ViewHolder holder;
    if(view == null){
        holder = new ViewHolder();
        view = inflater.inflate(R.layout.beg_list_item,null);
        holder.listHeading = (TextView) view.findViewById(R.id.beg_list_itemTextView);
    //  holder.listHash = (TextView) view.findViewById(R.id.listview_hashtags);
        holder.alphabetList = (ImageView) view.findViewById(R.id.beg_list_itemImageView);
        holder.favoriteImg = (ImageView) view.findViewById(R.id.favbtn);
        view.setTag(holder);

    }else{
        holder = (ViewHolder) view.getTag();
        }
        CodeList code = (CodeList) getItem(position);
        holder.listHeading.setText(codeList.get(position).getListHeading());
        imageLoader.DisplayImage(codeList.get(position).getAlphabetimg(),
                                holder.alphabetList);
    //  holder.listHash.setText(codeList.get(position).getListHashTags());                      

    if (checkFavoriteItem(code)) {
        holder.favoriteImg.setImageResource(R.drawable.favorite);
        holder.favoriteImg.setTag("yes");
    } else { …
Run Code Online (Sandbox Code Playgroud)

android sharedpreferences android-listview baseadapter

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

使用Volley的Post方法不起作用

嗨我正在使用Volley我的登录页面.我需要以这种方式传递数据

{
userID : '-988682425884628921',
email :'aditya@vyas.com',
passwd : '123ss'
}
Run Code Online (Sandbox Code Playgroud)

我正在使用POST方法发送数据,我已经在DHC中检查,Api在DHC中正常工作,我正在获得JSON响应,但是当我尝试使用Volley时,我无法得到响应.甚至在我的logcat中都没有任何错误.

JAVA代码

 RequestQueue mVolleyQueue = Volley.newRequestQueue(this);

    CustomRequest req = new CustomRequest(Request.Method.POST,url,null,
            new Response.Listener<JSONObject>() {
                @Override
                public void onResponse(JSONObject response) {
                    Log.v("tag","login response " + response);
                }
            }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            Log.v("tag","login error response " + error.getMessage());
        }
    }){
        @Override
        public Map<String, String> getParams() throws AuthFailureError {
            Map<String, String>  params = new HashMap<String, String>();

            params.put("userID", "-988682425884628921");
            params.put("email", "aditya@vyas.com");
            params.put("passwd", "123ss"); …
Run Code Online (Sandbox Code Playgroud)

android json android-volley dhc

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

Android:绘制带有斜角的形状

我想为我的按钮使用背景。但是当我使用 png 时,它会减慢应用程序的速度。因此我想使用 xml 形状,但我不知道如何进行切角(如图所示)。 在此处输入图片说明

现在我有以下形状,它只是一个矩形:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="@color/blue_semi_transparent"/>
    <padding android:bottom="10dp" android:right="10dp" android:top="10dp" android:left="10dp"/>
    <margin android:bottom="10dp" android:right="10dp" android:top="10dp" android:left="10dp"/>
</shape>
Run Code Online (Sandbox Code Playgroud)

如何绘制右下角?

android shape android-layout skew

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

如何将 json 对象存储到共享首选项?

我正在创建一个应用程序,在我的应用程序中,我收到响应并将其显示在自定义警报对话框中,直到这里它工作正常,现在我想做的是,如果用户从警报对话框中选择一个项目一次,它应该将其存储在偏好,这样就不需要每次都获取数据。

以下是我的代码片段。

我得到的以下回复是:

    {
    "states": [
        {
            "id": "1",
            "state_slug": "agra",
            "statename": "Agra"
        },
        {
            "id": "2",
            "state_slug": "andaman_and_nicobar_islands",
            "statename": "Andaman and Nicobar Islands"
        },
        {
            "id": "3",
            "state_slug": "andhra_pradesh",
            "statename": "Andhra Pradesh"
        },
        {
            "id": "4",
            "state_slug": "arunachal_pradesh",
            "statename": "Arunachal Pradesh"
        },
        {
            "id": "5",
            "state_slug": "assam",
            "statename": "Assam"
        },
        {
            "id": "6",
            "state_slug": "bihar",
            "statename": "Bihar"
        },
        {
            "id": "7",
            "state_slug": "bulandshahr",
            "statename": "Bulandshahr"
        },
        {
            "id": "8",
            "state_slug": "chhattisgarh",
            "statename": "Chhattisgarh"
        },
        {
            "id": "9",
            "state_slug": "dadra_and_nagar_haveli", …
Run Code Online (Sandbox Code Playgroud)

android json sharedpreferences android-alertdialog

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

Android代码使imageView轮不起作用

我正在努力使自己ImageView顺利。我已经编写了以下代码,使其看起来是圆形的,但不知何故它仍然显示方形ImageView。[使用毕加索获取图像]

Java代码:

ImageView iv = (ImageView) addLinkDialog.findViewById(R.id.group_icon_jsoup);
Picasso.with(getBaseContext()).load(GroupImageUrl).into(iv);
iv.setBackgroundResource(R.drawable.icon_img);
Run Code Online (Sandbox Code Playgroud)

ImageView代码:

<ImageView
    android:id="@+id/group_icon_jsoup"
    android:layout_width="75dp"
    android:layout_height="75dp"
    android:layout_gravity="center"
    android:layout_margin="8dp"
    android:background="@drawable/icon_img" />
Run Code Online (Sandbox Code Playgroud)

@ drawable / icon_img.xml:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <item android:drawable="@drawable/circle"/>
</layer-list>
Run Code Online (Sandbox Code Playgroud)

@ drawable / circle.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:innerRadius="0dp"
    android:shape="ring"
    android:thicknessRatio="1.9"
    android:useLevel="false" >
<solid android:color="@android:color/transparent" />

<stroke
    android:width="10dp"
    android:color="@android:color/white" />
</shape>
Run Code Online (Sandbox Code Playgroud)

xml android image imageview android-layout

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

如何在Android中检查布尔值?

在我的Android应用程序中,有两种登录类型。用户可以使用Facebook或Google+登录。用户成功登录后,它将显示该特定社交帐户中的数据。例如,当用户使用Facebook登录时,它将显示来自Facebook的数据。我已经包含了我的代码:

demo.java

boolean isFacebook;

  if (!isFacebook) {
        txtName.setText(PrefUtils.getCurrentUser(WelcomeScreenActivity.this).firstname);
        txtEmail.setText(PrefUtils.getCurrentUser(WelcomeScreenActivity.this).email);

        // fetching facebook's profile picture
        new AsyncTask<Void, Void, Void>() {
            @Override
            protected Void doInBackground(Void... params) {
                URL imageURL = null;
                try {
                    imageURL = new URL("https://graph.facebook.com/" + user.facebookID + "/picture?type=small");
                } catch (MalformedURLException e) {
                    e.printStackTrace();
                }
                try {
                    bitmap = BitmapFactory.decodeStream(imageURL.openConnection().getInputStream());

                } catch (IOException e) {
                    e.printStackTrace();
                }
                return null;
            }

            @Override
            protected void onPostExecute(Void aVoid) {
                super.onPostExecute(aVoid);
                imgProfile.setImageBitmap(bitmap);

            }
        }.execute();

    } else {
        isFacebook = false;
         SharedPreferences pref = …
Run Code Online (Sandbox Code Playgroud)

android boolean-logic facebook

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

如何删除饼图中的底部空间?

我在我的应用程序中使用饼图,现在饼图显示正常,唯一的问题是饼图底部的空间。以下是饼图的代码,并输出我想要的和我想要得到的。

使用此库绘制饼图

https://github.com/PhilJay/MPAndroidChart

 PieChart pieChart = (PieChart) view.findViewById(R.id.fragment_chart);
        pieChart.setUsePercentValues(true);
        Display display = getActivity().getWindowManager().getDefaultDisplay();
        int height = display.getHeight();  // deprecated

        int offset = (int)(height * 0.65); /* percent to move */

       /* RelativeLayout.LayoutParams rlParams =
                (RelativeLayout.LayoutParams)pieChart.getLayoutParams();
        rlParams.setMargins(0, 0, 0, -offset);
        pieChart.setLayoutParams(rlParams);*/
        // IMPORTANT: In a PieChart, no values (Entry) should have the same
        // xIndex (even if from different DataSets), since no values can be
        // drawn above each other.
        ArrayList<PieEntry> yvalues = new ArrayList<PieEntry>();
        yvalues.add(new PieEntry(8f, 0));
        yvalues.add(new PieEntry(15f, 1)); …
Run Code Online (Sandbox Code Playgroud)

android android-layout pie-chart mpandroidchart

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