2017-04-24 5 views
-2

アクセス時にアプリケーションをクラッシュさせるemployeeListフラグメントがあります。コードには詰まり線はなく、スタックトレース内のアラームもありません。私は、scrollViewがこれを引き起こしているかもしれないという愚かさを持っています。ここでは、コードscrollviewは断片的に機能しますか?

ManageFragment.java

package com.teslaqubitsins.fasih.teslahcm; 


import android.content.Context; 
import android.content.DialogInterface; 
import android.content.Intent; 
import android.database.Cursor; 
import android.database.sqlite.SQLiteDatabase; 
import android.os.Bundle; 
import android.support.v4.app.Fragment; 
import android.support.v4.app.FragmentTransaction; 
import android.support.v7.app.AlertDialog; 
import android.view.LayoutInflater; 
import android.view.View; 
import android.view.ViewGroup; 
import android.widget.AdapterView; 
import android.widget.Button; 
import android.widget.EditText; 
import android.widget.ListView; 

import java.util.ArrayList; 

import static android.content.Context.MODE_PRIVATE; 
import static android.database.sqlite.SQLiteDatabase.openOrCreateDatabase; 


public class ManageFragment extends Fragment { 

    EmployeeDatasource mEmployeeDatasource; 
    View rootView; 

    public ManageFragment() { 
    } 


    @Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container, 
          Bundle savedInstanceState) { 
     super.onCreateView(inflater, container, savedInstanceState); 
     rootView = inflater.inflate(R.layout.fragment_manage, container, false); 
     mEmployeeDatasource = new EmployeeDatasource(getActivity()); 
     final ArrayList<Employee> employeeArrayList = mEmployeeDatasource.getList(); 
     ListView mListView = (ListView) getActivity().findViewById(R.id.employeeList_listView); 
     EmployeeAdapter mEmployeeAdapter = new EmployeeAdapter(this.getActivity(), R.layout.row_employee_list, employeeArrayList); 
     mListView.setAdapter(mEmployeeAdapter); 
     mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { 
      @Override 
       public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { 
       EmployeeDetailFragment detailedemployee = new EmployeeDetailFragment(); 
       Employee item = employeeArrayList.get(i); 
       EmployeeDetailFragment.mEmployee = item; 
       FragmentTransaction ft = getFragmentManager().beginTransaction(); 
       ft.replace(R.id.content, detailedemployee); 
       ft.addToBackStack(null); 
       ft.commit(); 

      } 
     }); 
     return rootView; 
    } 
} 

fragment_manage.xml

<FrameLayout 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" 
    tools:context="com.teslaqubitsins.fasih.teslahcm.ManageFragment"> 

    <!-- TODO: Update blank fragment layout --> 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 
     <ListView 
      android:id="@+id/employeeList_listView" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 

     </ListView> 

    </LinearLayout> 

</FrameLayout> 

row_employee_list.xml

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" android:layout_height="match_parent"> 
    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" 
     android:padding="2dp"> 

     <LinearLayout 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="7" 
      android:orientation="vertical"> 

      <ImageView 
       android:id="@+id/row_employee_imageView" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:adjustViewBounds="true" 
       android:scaleType="fitXY" 
       android:src="@drawable/ic_stub" /> 

     </LinearLayout> 

     <LinearLayout 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:layout_weight="3" 
      android:orientation="vertical" 
      android:padding="5dp"> 

      <TextView 
       android:id="@+id/row_employee_name" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:maxLines="1" 
       android:text="Employee Name" 
       android:textSize="20sp" /> 

      <TextView 
       android:id="@+id/row_employee_salary" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_margin="5dp" 
       android:maxLines="1" 
       android:text="120 PKR" /> 
     </LinearLayout> 
    </LinearLayout> 

</FrameLayout> 
です

誰かが問題の解決に手伝ってください。

LOGS

04-24 15:17:31.223 1314: 1314 E/   ]                   Couldn't opendir /data/app/vmdl1759858640.tmp: No such file or 

directory 04-24 15:17:32.773 2184-2184/com.google.android.googlequicksearchbox:search W/LocationOracle: Starting background requests 04-24 15:17:33.123 2048-2298/com.google.android.gms.persistent W/GCoreFlp: No location to return for getLastLocation() 04-24 15:17:33.124 2048-2298/com.google.android.gms.persistent W/GCoreFlp: No location to return for getLastLocation() 04-24 15:17:35.478 2048-2960/com.google.android.gms.persistent I/GCoreUlr: Starting service, intent=Intent { act=com.google.android.location.reporting.ACTION_UPDATE_WORLD cmp=com.google.android.gms/com.google.android.location.reporting.service.DispatchingService (has extras) }, extras=Bundle[{receiverAction=android.intent.action.BOOT_COMPLETED}] 04-24 15:17:36.013 2048-2986/com.google.android.gms.persistent I/GCoreUlr: WorldUpdater received intent Intent { act=com.google.android.location.reporting.ACTION_UPDATE_WORLD cmp=com.google.android.gms/com.google.android.location.reporting.service.DispatchingService (has extras) } with receiverAction android.intent.action.BOOT_COMPLETED 04-24 15:17:36.533 2048-2990/com.google.android.gms.persistent I/GCoreUlr: Starting service, intent=Intent { act=com.google.android.location.reporting.ACTION_UPDATE_WORLD cmp=com.google.android.gms/com.google.android.location.reporting.service.DispatchingService (has extras) }, extras=Bundle[{receiverAction=com.google.android.location.internal.server.ACTION_RESTARTED}] 04-24 15:17:36.575 2048-2365/com.google.android.gms.persistent I/GCoreUlr: Starting service, intent=Intent { act=com.google.android.location.reporting.ACTION_UPDATE_WORLD cmp=com.google.android.gms/com.google.android.location.reporting.service.DispatchingService (has extras) }, extras=Bundle[{receiverAction=com.google.android.location.reporting.PHENOTYPE_FLAGS_CHANGED}] 04-24 15:17:37.325 3106-3106/? W/dex2oat: /system/bin/dex2oat 
--runtime-arg -classpath --runtime-arg & --instruction-set=x86 --instruction-set-features=smp,ssse3,-sse4.1,-sse4.2,-avx,-avx2,-lock_add,-popcnt 
--runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=x86 --instruction-set-features=default --dex-file=/data/user/0/com.google.android.gms/app_fb/f.apk --oat-fd=51 --oat-location=/data/user/0/com.google.android.gms/app_fb/f.dex --compiler-filter=speed 04-24 15:17:37.325 3106-3106/? I/dex2oat: /system/bin/dex2oat 
--dex-file=/data/user/0/com.google.android.gms/app_fb/f.apk --oat-fd=51 --oat-location=/data/user/0/com.google.android.gms/app_fb/f.dex --compiler-filter=speed 04-24 15:17:37.780 2048-2298/com.google.android.gms.persistent W/GCoreFlp: No location to return for getLastLocation() 04-24 15:17:37.780 2048-2298/com.google.android.gms.persistent W/GCoreFlp: No location to return for getLastLocation() 04-24 15:17:37.920 2048-2986/com.google.android.gms.persistent I/GCoreUlr: GMS FLP location and AR updates requested: {"description":"stationary","newRequest":true,"samplePeriodMs":2160000,"sampleReason":"stationary","sampleSource":"internal","timestampMs":1493029056848} 04-24 15:17:38.057 2048-2986/com.google.android.gms.persistent I/GCoreUlr: WorldUpdater received intent Intent { act=com.google.android.location.reporting.ACTION_UPDATE_WORLD cmp=com.google.android.gms/com.google.android.location.reporting.service.DispatchingService (has extras) } with receiverAction com.google.android.location.internal.server.ACTION_RESTARTED 04-24 15:17:38.064 2048-2986/com.google.android.gms.persistent I/GCoreUlr: WorldUpdater:com.google.android.location.internal.server.ACTION_RESTARTED: Ensuring that reporting is active for [account#7#] 04-24 15:17:38.069 2048-2986/com.google.android.gms.persistent I/GCoreUlr: WorldUpdater received intent Intent { act=com.google.android.location.reporting.ACTION_UPDATE_WORLD cmp=com.google.android.gms/com.google.android.location.reporting.service.DispatchingService (has extras) } with receiverAction com.google.android.location.reporting.PHENOTYPE_FLAGS_CHANGED 04-24 15:17:38.103 2048-2986/com.google.android.gms.persistent I/GCoreUlr: WorldUpdater:com.google.android.location.reporting.PHENOTYPE_FLAGS_CHANGED: Ensuring that reporting is active for [account#7#] 04-24 15:17:38.430 2048-2048/com.google.android.gms.persistent E/ActivityThread: Service com.google.android.location.places.service.PlaceDetectionAsyncService has leaked IntentReceiver [email protected] that was originally registered here. Are you missing a call to unregisterReceiver()? 
                       android.app.IntentReceiverLeaked: Service com.google.android.location.places.service.PlaceDetectionAsyncService has leaked IntentReceiver [email protected] that was originally registered here. Are you missing a call to unregisterReceiver()? 
                        at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:1159) 
                        at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:946) 
                        at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1302) 
                        at android.app.ContextImpl.registerReceiver(ContextImpl.java:1282) 
                        at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:593) 
                        at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:593) 
                        at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:593) 
                        at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:593) 
                        at amrb.run(:com.google.android.gms:4414) 
                        at android.os.Handler.handleCallback(Handler.java:751) 
                        at android.os.Handler.dispatchMessage(Handler.java:95) 
                        at android.os.Looper.loop(Looper.java:154) 
                        at android.os.HandlerThread.run(HandlerThread.java:61) 04-24 15:17:38.545 2048-2048/com.google.android.gms.persistent E/ActivityThread: Service com.google.android.location.places.service.PlaceDetectionAsyncService has leaked IntentReceiver [email protected] that was originally registered here. Are you missing a call to unregisterReceiver()? 
                       android.app.IntentReceiverLeaked: Service com.google.android.location.places.service.PlaceDetectionAsyncService has leaked IntentReceiver [email protected] that was originally registered here. Are you missing a call to unregisterReceiver()? 
                        at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:1159) 
                        at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:946) 
                        at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1302) 
                        at android.app.ContextImpl.registerReceiver(ContextImpl.java:1282) 
                        at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:593) 
                        at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:593) 
                        at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:593) 
                        at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:593) 
                        at amrb.run(:com.google.android.gms:4414) 
                        at android.os.Handler.handleCallback(Handler.java:751) 
                        at android.os.Handler.dispatchMessage(Handler.java:95) 
                        at android.os.Looper.loop(Looper.java:154) 
                        at android.os.HandlerThread.run(HandlerThread.java:61) 04-24 15:17:42.411 2048-2298/com.google.android.gms.persistent W/GCoreFlp: No location to return for getLastLocation() 04-24 15:17:42.411 2048-2298/com.google.android.gms.persistent W/GCoreFlp: No location to return for getLastLocation() 

MainActivity.java

package com.teslaqubitsins.fasih.teslahcm; 

import android.os.Bundle; 
import android.support.annotation.NonNull; 
import android.support.design.widget.BottomNavigationView; 
import android.support.v4.app.Fragment; 
import android.support.v4.app.FragmentManager; 
import android.support.v4.app.FragmentTransaction; 
import android.support.v7.app.AppCompatActivity; 
import android.view.MenuItem; 
import android.view.Window; 
import android.view.WindowManager; 
import android.widget.TextView; 

public class MainActivity extends AppCompatActivity { 

    private TextView mTextMessage; 

    private static final String TAG = MainActivity.class.getSimpleName(); 
    private BottomNavigationView bottomNavigation; 
    private Fragment fragment; 
    private FragmentManager fragmentManager; 


    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 

     requestWindowFeature(Window.FEATURE_NO_TITLE); 
     getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
       WindowManager.LayoutParams.FLAG_FULLSCREEN); 

     setContentView(R.layout.activity_main); 
     bottomNavigation = (BottomNavigationView)findViewById(R.id.navigation1); 
     bottomNavigation.inflateMenu(R.menu.menu); 
     fragmentManager = getSupportFragmentManager(); 
     bottomNavigation.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() { 
     @Override 
     public boolean onNavigationItemSelected(@NonNull MenuItem item) { 
     int id = item.getItemId(); 
     switch (id){ 
     case R.id.bb_menu_home: 
     fragment = new HomeFragment(); 
     break; 
     case R.id.bb_menu_contact: 
     fragment = new ContactFragment(); 
     break; 
     case R.id.bb_menu_manage: 
     fragment = new ManageFragment(); 
     break; 
     case R.id.bb_menu_queries: 
     fragment = new QueriesFragment(); 
     break; 
     case R.id.bb_menu_careers: 
     fragment = new CareersFragment(); 
     break; 
      default: 
      fragment = new HomeFragment(); 
     } 
final FragmentTransaction transaction = fragmentManager.beginTransaction(); 
     transaction.replace(R.id.content, fragment).commit(); 
     return true; 
     } 
     }); 
     } 

} 
+1

あなたのアプリがクラッシュした場合は、間違いなく記録されますがあります。ログを投稿する! – Abbas

+0

はい、できます。あなたが何か問題に直面している場合は、[ここで考えられる解答のstackoverflowのリンクがある](http://stackoverflow.com/questions/33863791/scrollview-doesnt-work-in-fragment) –

+0

@Abbas、チェックしてください。 – fasih

答えて

0

は交換してください:

FragmentTransaction ft = getFragmentManager().beginTransaction(); 

で:

+0

しました。残念ながらそれは以前のように墜落した。 – fasih

+0

'EmployeeDetailFragment detailedemployee =新しいEmployeeDetailFragment(); 従業員アイテム= employeeArrayList.get(i); EmployeeDetailFragment.mEmployee = item; FragmentTransaction ft = getChildFragmentManager()。beginTransaction(); ft.replace(R.id.content、detailedemployee); ft.addToBackStack(null); ft.commitを(); ' – fasih

+0

ログが何を言うのですか? @fasih – MichaelStoddart

関連する問題