小编buk*_*may的帖子

java.lang.ClassCastException:android.view.ViewGroup $ LayoutParams无法强制转换为android.widget.RelativeLayout $ LayoutParams

您好我刚刚编辑了我的XML,我把幻灯片菜单代码放在我的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:background="#ffffff" >

    <ListView 
        android:id="@+id/menu_content_menulist"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:padding="8dp"

        android:cacheColorHint="@android:color/transparent" 
        android:divider="@null"
        android:listSelector="@null"/>      
    <RelativeLayout 
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <com.mozaik.tangsel.side_menu_scroll.ScrollerLinearLayout       
            android:id="@+id/menu_content_side_slide_layout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"        
            android:orientation="verti_

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:id="@+id/content_statis"        
        android:orientation="vertical"
        android:background="@drawable/bg_app"
         >

        <include layout="@layout/layout_action_bar" />
    <ScrollView
        android:id="@+id/SV"
        android:layout_width="fill_parent"
        android:layout_height="match_parent"
        android:fillViewport="true" 
        >

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

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_margin="4dp"
                android:background="@drawable/inbox_interface"
                android:orientation="vertical" >

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

                    <ImageView
                        android:id="@+id/ImageMozaikTangsel"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:layout_margin="10dip" />

                </LinearLayout>

                <LinearLayout
                    android:id="@+id/tabMozaikTangselLayout"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical" >
                </LinearLayout>

            </LinearLayout>

        </LinearLayout>

</ScrollView>

   </LinearLayout>
</com.mozaik.tangsel.side_menu_scroll.ScrollerLinearLayout>
</RelativeLayout> …
Run Code Online (Sandbox Code Playgroud)

java android android-layout layoutparams android-relativelayout

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

如何使用listview适配器中的单击按钮打开菜单上下文Android?

如何使用listview适配器中的单击按钮打开菜单上下文Android?

我尝试使用我的代码,但没有显示菜单上下文,

 public View getView(int position, View convertView, ViewGroup parent) {
      vi=convertView;
    if(convertView==null)
        vi = inflater.inflate(R.layout.tulisan_komentar_list_item,parent, false);
    LinearLayout content_favorite= (LinearLayout)vi.findViewById(R.id.content_favorite);
    final TextView date_komentar = (TextView)vi.findViewById(R.id.date_komentar); // artist name
    final TextView isi_komentar = (TextView)vi.findViewById(R.id.isi_komentar); // duration
    final TextView nama_komentar = (TextView)vi.findViewById(R.id.nama_komentar); // duration
    final TextView id_tulisan_komentar = (TextView)vi.findViewById(R.id.id_tulisan_komentar); // duration
    final ImageButton act_komentar = (ImageButton)vi.findViewById(R.id.act_komentar);
    ImageView thumb_image=(ImageView)vi.findViewById(R.id.avatar_komentar); // thumb image

    HashMap<String, String> tulisan = new HashMap<String, String>();
    tulisan = data.get(position);

    // Setting all values in listview
    date_komentar.setText(tulisan.get(ContentCommentActivity.TAG_DATE_KOMENTAR));
    isi_komentar.setText(tulisan.get(ContentCommentActivity.TAG_ISI_KOMENTAR));
    nama_komentar.setText(tulisan.get(ContentCommentActivity.TAG_NAMA_KOMENTAR));
    id_tulisan_komentar.setText(tulisan.get(ContentCommentActivity.TAG_ID_TULISAN_KOMENTAR)); …
Run Code Online (Sandbox Code Playgroud)

android listview adapter android-contextmenu

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

意外的响应代码500 URL API Android应用

当我访问URL API时,我遇到问题"意外的响应代码500".

这是我的代码与齐射库:

String url= "http://103.241.24.35/android/android_login_api/index.php";

 public void detailURL(String url) {
            Log.v("Android Spinner JSON Data Activity", url);
             queue = Volley.newRequestQueue(this);
            StringRequest sr = new StringRequest(Request.Method.POST,url, new Response.Listener<String>() {
                @Override
                public void onResponse(String response) {
                    ProgressLoadStartLogin.setVisibility(View.GONE);
                    displaystatis_kontenDetail(response);
                    btn_enable();
                }
            }, new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {

                    if( error instanceof NetworkError) {
                    } else if( error instanceof ServerError) {
                    } else if( error instanceof AuthFailureError) {
                    } else if( error instanceof ParseError) {
                    } else if( error instanceof NoConnectionError) …
Run Code Online (Sandbox Code Playgroud)

android android-volley

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

如何设置检查默认单选按钮android与警告对话框?

任何身体帮我...当启动时如何设置检查默认单选按钮和警告对话框..?

这是我的代码,例如:我想在项目为"15"时启动单选按钮

public void showDialog()
{
    final CharSequence[] items = {"5", "10", "15","20"};

    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);

    alertDialogBuilder.setTitle("Set limit article");

    alertDialogBuilder.setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int item) {
                Toast.makeText(SettingAppDisplay.this, "You selected item No." + item + ": " + items[item], Toast.LENGTH_SHORT).show();

                if (items[item].equals("5")) {
                    //do what you want
                }
                else if (items[item].equals("10")) {
                    //do what you want                                  
                }
                else if (items[item].equals("15")) {
                    //do what you want
                }
                else if (items[item].equals("20")) {
                    //do what you …
Run Code Online (Sandbox Code Playgroud)

alert android dialog button radio

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

如何从SD卡中保存并获取图像裁剪Android的路径?

我从http://www.londatiga.net/featured-articles/how-to-select-and-crop-image-on-android/学习裁剪图像教程,但结果还是裁剪后,图像无法保存在SD卡中,怎么解决?

这个代码

 package net.londatiga.android;

import java.io.File;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.app.AlertDialog;

import android.content.ActivityNotFoundException;
import android.content.ComponentName;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.ResolveInfo;

import android.graphics.Bitmap;
import android.provider.MediaStore;
import android.view.View;

import android.net.Uri;

import android.os.Bundle;
import android.os.Environment;

import android.widget.Button;
import android.widget.ArrayAdapter;
import android.widget.Toast;
import android.widget.ImageView;

public class MainActivity extends Activity {
    private Uri mImageCaptureUri;
    private ImageView mImageView;

    private static final int PICK_FROM_CAMERA = 1;
    private static final int CROP_FROM_CAMERA = 2;
    private static final int PICK_FROM_FILE = 3;

    @Override …
Run Code Online (Sandbox Code Playgroud)

android image crop

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

Google C2D_MESSAGE应用程序没有定义权限?

我的代码有问题,我刚刚关注GCM推送消息的谷歌指南,我收到此错误:

06-07 10:51:04.371: E/AndroidRuntime(29686): FATAL EXCEPTION: main
06-07 10:51:04.371: E/AndroidRuntime(29686): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.droidersuin.project/com.droidersuin.pushnotifications.PushMainActivity}: java.lang.IllegalStateException: Application does not define permission com.droidersuin.project.permission.C2D_MESSAGE
06-07 10:51:04.371: E/AndroidRuntime(29686):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1959)
06-07 10:51:04.371: E/AndroidRuntime(29686):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1984)
06-07 10:51:04.371: E/AndroidRuntime(29686):    at android.app.ActivityThread.access$600(ActivityThread.java:126)
06-07 10:51:04.371: E/AndroidRuntime(29686):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1150)
06-07 10:51:04.371: E/AndroidRuntime(29686):    at android.os.Handler.dispatchMessage(Handler.java:99)
06-07 10:51:04.371: E/AndroidRuntime(29686):    at android.os.Looper.loop(Looper.java:137)
06-07 10:51:04.371: E/AndroidRuntime(29686):    at android.app.ActivityThread.main(ActivityThread.java:4456)
06-07 10:51:04.371: E/AndroidRuntime(29686):    at java.lang.reflect.Method.invokeNative(Native Method)
06-07 10:51:04.371: E/AndroidRuntime(29686):    at java.lang.reflect.Method.invoke(Method.java:511)
06-07 10:51:04.371: E/AndroidRuntime(29686):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:787)
06-07 10:51:04.371: E/AndroidRuntime(29686):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:554)
06-07 …
Run Code Online (Sandbox Code Playgroud)

android push-notification google-cloud-messaging

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

删除所有项目(可见且不可见)自定义列表视图Android?

我的代码有问题.我想listview用以下代码删除自定义中的所有项目:

public void delete_all()
{
    int count = getCount();
    if(count>0)
      {
         for (int i = 0; i < count; i++) 
          {
              data.remove(data.get(i));
          }
       notifyDataSetChanged();
    }
}

public Object getItem(int position) 
{
    return position;
}
Run Code Online (Sandbox Code Playgroud)

但结果,只有项目可见删除的地方,例如:有count = 5项,结果只有3 项可见被删除,2项未被删除,

data.remove(data.get(i)); 
Run Code Online (Sandbox Code Playgroud)

我试着改变data.remove(i); 同样的结果;

和该代码的logcat是

> 04-15 13:07:58.340: E/AndroidRuntime(2111): FATAL EXCEPTION: main
04-15 13:07:58.340: E/AndroidRuntime(2111): java.lang.IllegalStateException: Could not execute method of the activity
04-15 13:07:58.340: E/AndroidRuntime(2111):     at android.view.View$1.onClick(View.java:3044)
04-15 13:07:58.340: E/AndroidRuntime(2111):     at android.view.View.performClick(View.java:3511)
04-15 13:07:58.340: E/AndroidRuntime(2111): …
Run Code Online (Sandbox Code Playgroud)

android android-listview

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