Моя проблема заключается в том, что при запуске моего приложения на эмуляторе Android приложение запускается, но после входа в систему приложение быстро вылетает и отображает всплывающее окно: «К сожалению, остановилось». Я просмотрел код и тщательно проверил Интернет для ответа. Да, я новичок в разработке Android. Я просмотрел ошибки, которые были созданы LogCat, но не знаю проблемы и где ее найти на основе полученных мной ошибок.Android - RuntimeException - ClassCastException
Вот LogCat:
11-01 08:09:37.650: W/dalvikvm(2382): threadid=1: thread exiting with uncaught exception (group=0xb0d02b20)
11-01 08:09:37.650: E/AndroidRuntime(2382): FATAL EXCEPTION: main
11-01 08:09:37.650: E/AndroidRuntime(2382): Process: com.pozs.myappz, PID: 2382
11-01 08:09:37.650: E/AndroidRuntime(2382): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.pozs.myappz/com.pozs.myappz.Tabbedmaincontroller}: java.lang.ClassCastException: com.handmark.pulltorefresh.library.PullToRefreshGridView$InternalGridViewSDK9 cannot be cast to com.penq.utils.LoadMoreGrid
11-01 08:09:37.650: E/AndroidRuntime(2382): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
11-01 08:09:37.650: E/AndroidRuntime(2382): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
11-01 08:09:37.650: E/AndroidRuntime(2382): at android.app.ActivityThread.access$800(ActivityThread.java:135)
11-01 08:09:37.650: E/AndroidRuntime(2382): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
11-01 08:09:37.650: E/AndroidRuntime(2382): at android.os.Handler.dispatchMessage(Handler.java:102)
11-01 08:09:37.650: E/AndroidRuntime(2382): at android.os.Looper.loop(Looper.java:136)
11-01 08:09:37.650: E/AndroidRuntime(2382): at android.app.ActivityThread.main(ActivityThread.java:5017)
11-01 08:09:37.650: E/AndroidRuntime(2382): at java.lang.reflect.Method.invokeNative(Native Method)
11-01 08:09:37.650: E/AndroidRuntime(2382): at java.lang.reflect.Method.invoke(Method.java:515)
11-01 08:09:37.650: E/AndroidRuntime(2382): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
11-01 08:09:37.650: E/AndroidRuntime(2382): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
11-01 08:09:37.650: E/AndroidRuntime(2382): at dalvik.system.NativeStart.main(Native Method)
11-01 08:09:37.650: E/AndroidRuntime(2382): Caused by: java.lang.ClassCastException: com.handmark.pulltorefresh.library.PullToRefreshGridView$InternalGridViewSDK9 cannot be cast to com.penq.utils.LoadMoreGrid
11-01 08:09:37.650: E/AndroidRuntime(2382): at com.pozs.myappz.GridFragment.onCreateView(GridFragment.java:70)
11-01 08:09:37.650: E/AndroidRuntime(2382): at android.support.v4.app.Fragment.performCreateView(Fragment.java:1786)
11-01 08:09:37.650: E/AndroidRuntime(2382): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:947)
11-01 08:09:37.650: E/AndroidRuntime(2382): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1126)
11-01 08:09:37.650: E/AndroidRuntime(2382): at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:739)
11-01 08:09:37.650: E/AndroidRuntime(2382): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1489)
11-01 08:09:37.650: E/AndroidRuntime(2382): at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:548)
11-01 08:09:37.650: E/AndroidRuntime(2382): at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1171)
11-01 08:09:37.650: E/AndroidRuntime(2382): at android.app.Activity.performStart(Activity.java:5241)
11-01 08:09:37.650: E/AndroidRuntime(2382): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2168)
11-01 08:09:37.650: E/AndroidRuntime(2382): ... 11 more
Ниже приводится GridFragment.java:
package com.pozs.myappz;
import java.util.ArrayList;
<...other import here deleted...>
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.handmark.pulltorefresh.library.PullToRefreshBase;
import com.handmark.pulltorefresh.library.PullToRefreshBase.OnRefreshListener2;
import com.handmark.pulltorefresh.library.PullToRefreshGridView;
import com.penq.utils.LoadMoreGrid;
import com.penq.utils.LoadMoreGrid.OnLoadMoreListener;
import com.pozs.Vo.FeedsVo;
import com.pozs.peak.adapter.GridAdapter;
import com.pozs.peak.utils.CommonUtils;
public class GridFragment extends Fragment {
public static ArrayList<FeedsVo> abcd;
private GridAdapter ga;
private String m_urlResp, m_userIdVal;
private Bundle m_bundle;
private String profileName, imageUrl, m_hearts, m_likes, m_ImageID,
m_videoUrl, m_swebLinkUrl;
private ProgressDialog pDlg;
private Context m_context;
private Boolean m_resultStatus, m_isHeartbyMe = false,
m_isLikebyMe = false,isDone=false;
private TextView m_tvNoData, m_tvTitle;
int pageval = 1;
private PullToRefreshGridView mPullRefreshGridView;
private LoadMoreGrid mGridView;
private ImageView m_ivFollower;
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.feedpage, container, false);
m_context = GridFragment.this.getActivity();
abcd = new ArrayList<FeedsVo>();
pDlg = new ProgressDialog(m_context);
m_bundle = this.getArguments();
m_userIdVal = m_bundle.getString("userId");
m_tvNoData = (TextView) v.findViewById(R.id.tv_nodata);
m_tvTitle = (TextView) v.findViewById(R.id.fd_tvTitle);
mPullRefreshGridView = (PullToRefreshGridView) v
.findViewById(R.id.feedgrid);
mGridView = (LoadMoreGrid) mPullRefreshGridView.getRefreshableView(); <--Line 70 as it is indicated in logcat
m_ivFollower = (ImageView) v.findViewById(R.id.fd_ivFollow);
Typeface font = Typeface.createFromAsset(m_context.getAssets(),
"helvetica.ttf");
m_tvTitle.setTypeface(font);
ga = new GridAdapter(abcd, getActivity());
mGridView.setOnLoadMoreListener(new OnLoadMoreListener() {
public void onLoadMore() {
feedtask Feed = new feedtask();
Feed.execute();
}
});
<...other codes here deleted...>
if (myappz.m_FeedsScreen == "" || myappz.m_FeedsScreen == null) {
pageval = 1;
feedtask Feed = new feedtask();
Feed.execute();
mGridView.setAdapter(ga);
abcd.clear();
Log.e("GridFragment", "Resume Called");
myappz.m_sFollowerId = null;
}
}
}
выше, кажется, хорошо для меня тоже, конечно, я пропустил что-то здесь. Любая помощь будет оценена.
Спасибо!
mPullRefreshGridView.getRefreshableView() нельзя передать в LoadMoreGrid. –
Спасибо. возможно из-за другого типа. – KeLaM