单击片段中的listvies项时启动Actitvity

时间:2017-06-18 07:08:28

标签: java android listview android-fragments

我在片段中有一个列表视图,我想调用一个活动" DetailActivity"这将显示每个项目的详细信息。

问题是当我点击项目列表时我的应用程序崩溃了。我不知道片段内是否需要任何其他方法来实现这一点。

public class ParksFragment extends Fragment {
    private ArrayList<Park> parks = new ArrayList<>();


    public ParksFragment() {
        // Required empty public constructor
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        View rootView = inflater.inflate(layout.fragment_parks, container, false);

        parks.add(new Park("Artificial Lake of Tirana", "The Grand Park of Tirana, also known as the Tirana Park on the Artificial Lake or even the Park of Saint Procopius, is a 230 hectare public park situated on the southern part of Tirana.",
                "At the end of Rruga Sami Frasheri.", R.drawable.artificiallake, "Always open", "No closing day", "Free"));
        parks.add(new Park("Zoo park", "The only one of its kind in Albania, Tirana Zoo is concentrated in an area of \u200B\u200B7 hectares in the southern part of town, between the Grand Park and the Botanic Garden of Tirana . The zoo was established in 1966.",
                "Near Rruga Liqeni i Thate", R.drawable.zoopark, "Always open", "No closing day", "Free"));
        parks.add(new Park("Memorial park of the Cemetery of the Nation's Martyrs", "The National Martyrs Cemetery of Albania is the largest cemetery in Albania, located on a hill overlooking Tirana. The \"Mother Albania\" statue is located at the Cemetery.",
                "Near street Rruga Ligor Lubonja", R.drawable.memorialpark, "Always open", "No closing day", "Free"));
        parks.add(new Park("Kashar park", "The main core of Kashar’s Park, is the Reservoir of Purez- Kus. The reservoir and its surrounding territory are considered as one of the most picturesque and biologically unsoiled suburbs of Tirana.",
                "Kashar", R.drawable.kasharpark, "Always open", "No closing day", "Free"));
        parks.add(new Park("Vaqarr park", "The second park in Vaqarr, is a recreational area of 97 ha, that is more than useful to inhabitants in Tirana.",
                "Vaqarr", R.drawable.vaqarripark, "Always open", "No closing day", "Free"));
        parks.add(new Park("Farka Lake park", "To the East of the East of Tirana’s city center, Lake Farka is a local favorite for waterborne fun in Summer. Picnicking, jet and water skiing, swimming, boating, all the usual wet sports suspects.",
                "At Lake of Farka, near Rruga Pjeter Budi", R.drawable.farkapark, "Always open", "No closing day", "Free"));
        parks.add(new Park("Peza park", "Peza, a village approximately 20 minutes from the center of Tirana, is a popular place for locals to go for a coffee or lunch on the weekends to escape the city.",
                "Peze", R.drawable.pezapark, "Always open", "No closing day", "Free"));
        parks.add(new Park("Dajti Recreative park", "This park is one of the components of Dajti National Park, located 26 km east of Tirana and 50 km from \"Mother Teresa\" airport. This place is very frequented by tourists and is also known as the \"Natural Balcon of Tirana\" which offers recreation and accommodation facilities for tourists.",
                "Dajti mountain", R.drawable.dajtirecreative, "Always open", "No closing day", "Free"));
        parks.add(new Park("Dajti National park", "Dajti National Park is very important on local, national and regional level, for its biodiversity, landscape, recreational and cultural values. Among others it is considered as a live museum of the natural vertical structure of vegetation.",
                "Dajti mountain", R.drawable.dajtinational, "Always open", "No closing day", "Free"));
        parks.add(new Park("Botanic garden", "The Botanical Gardens of Tirana are scenic botanical gardens located in southern Tirana, Albania. It is the only botanical garden in Albania. Construction commenced in 1964, with the original site covering approximately 15 hectares.",
                "Near Zoo park", R.drawable.botanicpark, "Always open", "No closing day", "Free"));
        parks.add(new Park("Rinia park", "The park, 500 metres (1,600 ft) from the central square, was built in 1950[5] as part of a major urban development program which developed after World War II. It was initially a pleasant family park where inhabitants of Tirana could take their children.",
                "Near Bulevardi Deshmoret e Kombit and near Rruga Myslym Shyri", R.drawable.riniapark, "Always open", "No closing day", "Free"));

        ArrayAdapter<Park> adapter = new ParkArrayAdapter(getActivity(), 0, parks);


        ListView listView = (ListView) rootView.findViewById(R.id.customListView);
        listView.setAdapter(adapter);


        //add event listener so we can handle clicks
        AdapterView.OnItemClickListener adapterViewListener = new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Park par = parks.get(position);
                Intent intent = new Intent(ParksFragment.this.getActivity(), DetailActivity.class);
                intent.putExtra("image", par.getPark_image());
                intent.putExtra("title", par.getPark_title());
                intent.putExtra("description", par.getPark_description());
                intent.putExtra("streetname", par.getPark_streetname());
                intent.putExtra("openinghours", par.getOpenclosehour());
                intent.putExtra("closingday", par.getClosedday());
                intent.putExtra("price", par.getPrice());
                ParksFragment.this.getActivity().startActivity(intent);

            }

        };
        listView.setOnItemClickListener(adapterViewListener);
        return rootView;
    }

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {

        super.onViewCreated(view, savedInstanceState);
    }
}

我的细节:

public class DetailActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_detail);

        getSupportActionBar().setHomeButtonEnabled(true);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);

        ImageView imageView = (ImageView) findViewById(R.id.image);
        TextView titleTV = (TextView) findViewById(R.id.p_title);
        TextView streetnameTV = (TextView) findViewById(R.id.address);
        TextView descriptionTV = (TextView) findViewById(R.id.p_description);
        TextView openclosehourTV = (TextView) findViewById(R.id.openclose);
        TextView closingdayTV = (TextView) findViewById(R.id.closed);
        TextView priceTV = (TextView) findViewById(R.id.price);

        //collect our intent and populate our layout
        Intent intent = getIntent();
        String image = intent.getStringExtra("image");
        String title = intent.getStringExtra("title");
        String description = intent.getStringExtra("description");
        String streetname = intent.getStringExtra("streetname");
        String openclosehour = intent.getStringExtra("openclosehour");
        String closingday = intent.getStringExtra("closingday");
        String price = intent.getStringExtra("price");
        Integer imageID = this.getResources().getIdentifier(image, "drawable", this.getPackageName());

        //set elements
        imageView.setImageResource(imageID);
        titleTV.setText(title);
        descriptionTV.setText(description);
        streetnameTV.setText(streetname);
        openclosehourTV.setText(openclosehour);
        closingdayTV.setText(closingday);
        priceTV.setText("ALL" + price);

        //set the title of this activity to be the street name
        getSupportActionBar().setTitle(title);

    }
}

我的主要活动:

public class MainActivity extends AppCompatActivity {
    DrawerLayout mDrawerLayout;
    ActionBarDrawerToggle mToggle;
    private Toolbar mToolbar;
    FragmentTransaction fragmentTransaction;
    NavigationView navigationView;
    private ParksFragment mParksFragment;



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mParksFragment =  new ParksFragment();

        mToolbar = (Toolbar) findViewById(R.id.nav_actionbar);
        setSupportActionBar(mToolbar);

        mDrawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout);
        mToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.open, R.string.close);

        getSupportActionBar().setHomeButtonEnabled(true);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);

        mDrawerLayout.addDrawerListener(mToggle);
        mToggle.syncState();

        fragmentTransaction = getSupportFragmentManager().beginTransaction();
        fragmentTransaction.add(R.id.main_container,new HomeFragment());
        fragmentTransaction.commit();
        getSupportActionBar().setTitle("Home");
        navigationView = (NavigationView)findViewById(R.id.navigation_view);
        navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {

            @Override
            public boolean onNavigationItemSelected(@NonNull MenuItem item) {
                switch (item.getItemId()){
                    case R.id.home_category:
                        fragmentTransaction = getSupportFragmentManager().beginTransaction();
                        fragmentTransaction.replace(R.id.main_container, new HomeFragment());
                        fragmentTransaction.commit();
                        getSupportActionBar().setTitle("Home");
                        item.setChecked(true);
                        mDrawerLayout.closeDrawers();
                        break;

                    case R.id.parks_category:
                        fragmentTransaction = getSupportFragmentManager().beginTransaction();
                        fragmentTransaction.replace(R.id.main_container, new ParksFragment());
                        fragmentTransaction.commit();
                        getSupportActionBar().setTitle("Parks");
                        item.setChecked(true);
                        mDrawerLayout.closeDrawers();
                        break;

                    case R.id.monuments_category:
                        fragmentTransaction = getSupportFragmentManager().beginTransaction();
                        fragmentTransaction.replace(R.id.main_container, new MonumentsFragment());
                        fragmentTransaction.commit();
                        getSupportActionBar().setTitle("Monuments");
                        item.setChecked(true);
                        mDrawerLayout.closeDrawers();
                        break;

                    case R.id.theatrescinemas_category:
                        fragmentTransaction = getSupportFragmentManager().beginTransaction();
                        fragmentTransaction.replace(R.id.main_container, new TheatresFragment());
                        fragmentTransaction.commit();
                        getSupportActionBar().setTitle("Theatres and Cinemas");
                        item.setChecked(true);
                        mDrawerLayout.closeDrawers();
                        break;

                    case R.id.museums_category:
                        fragmentTransaction = getSupportFragmentManager().beginTransaction();
                        fragmentTransaction.replace(R.id.main_container, new MuseumsFragment());
                        fragmentTransaction.commit();
                        getSupportActionBar().setTitle("Museums");
                        item.setChecked(true);
                        mDrawerLayout.closeDrawers();
                        break;

                    case R.id.festivals_category:
                        fragmentTransaction = getSupportFragmentManager().beginTransaction();
                        fragmentTransaction.replace(R.id.main_container, new FestivalsFragment());
                        fragmentTransaction.commit();
                        getSupportActionBar().setTitle("Festivals and Activities");
                        item.setChecked(true);
                        mDrawerLayout.closeDrawers();
                        break;

                    case R.id.tips_category:
                        fragmentTransaction = getSupportFragmentManager().beginTransaction();
                        fragmentTransaction.replace(R.id.main_container, new TipsFragment());
                        fragmentTransaction.commit();
                        getSupportActionBar().setTitle("Local Tips");
                        item.setChecked(true);
                        mDrawerLayout.closeDrawers();
                        break;

                    case R.id.settings_category:
                        fragmentTransaction = getSupportFragmentManager().beginTransaction();
                        fragmentTransaction.replace(R.id.main_container, new SettingsFragment());
                        fragmentTransaction.commit();
                        getSupportActionBar().setTitle("Settings");
                        item.setChecked(true);
                        mDrawerLayout.closeDrawers();
                        break;
                }




                return false; }
        });

    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if (mToggle.onOptionsItemSelected(item)){
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
}

Logcat输出:

06-18 14:08:19.946 4333-11382/? W/FusedLocationProvider: I/O error: java.io.IOException: Timed out waiting for response from server
06-18 14:08:19.946 4333-11382/? W/FusedLocationProvider: No address is returned
06-18 14:08:21.042 4333-22630/? W/System.err: java.net.UnknownHostException: Unable to resolve host "www.google.com": No address associated with hostname
06-18 14:08:21.042 4333-22630/? W/System.err:     at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:125)
06-18 14:08:21.043 4333-22630/? W/System.err:     at java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:74)
06-18 14:08:21.043 4333-22630/? W/System.err:     at java.net.InetAddress.getAllByName(InetAddress.java:752)
06-18 14:08:21.043 4333-22630/? W/System.err:     at com.android.okhttp.internal.Network$1.resolveInetAddresses(Network.java:29)
06-18 14:08:21.043 4333-22630/? W/System.err:     at com.android.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:187)
06-18 14:08:21.043 4333-22630/? W/System.err:     at com.android.okhttp.internal.http.RouteSelector.nextProxy(RouteSelector.java:156)
06-18 14:08:21.043 4333-22630/? W/System.err:     at com.android.okhttp.internal.http.RouteSelector.next(RouteSelector.java:98)
06-18 14:08:21.043 4333-22630/? W/System.err:     at com.android.okhttp.internal.http.HttpEngine.createNextConnection(HttpEngine.java:345)
06-18 14:08:21.043 4333-22630/? W/System.err:     at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:328)
06-18 14:08:21.043 4333-22630/? W/System.err:     at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:246)
06-18 14:08:21.043 4333-22630/? W/System.err:     at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:457)
06-18 14:08:21.045 4333-22630/? W/System.err:     at com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:126)
06-18 14:08:21.045 4333-22630/? W/System.err:     at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:257)
06-18 14:08:21.045 4333-22630/? W/System.err:     at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getOutputStream(DelegatingHttpsURLConnection.java:218)
06-18 14:08:21.045 4333-22630/? W/System.err:     at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java)
06-18 14:08:21.045 4333-22630/? W/System.err:     at anwh.a(:com.google.android.gms:87)
06-18 14:08:21.045 4333-22630/? W/System.err:     at apwg.run(:com.google.android.gms:287)
06-18 14:08:21.045 4333-22630/? W/System.err:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
06-18 14:08:21.045 4333-22630/? W/System.err:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
06-18 14:08:21.045 4333-22630/? W/System.err:     at java.lang.Thread.run(Thread.java:761)
06-18 14:08:21.045 4333-22630/? W/System.err: Caused by: android.system.GaiException: android_getaddrinfo failed: EAI_NODATA (No address associated with hostname)
06-18 14:08:21.046 4333-22630/? W/System.err:     at libcore.io.Posix.android_getaddrinfo(Native Method)
06-18 14:08:21.046 4333-22630/? W/System.err:     at libcore.io.ForwardingOs.android_getaddrinfo(ForwardingOs.java:55)
06-18 14:08:21.046 4333-22630/? W/System.err:     at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:106)
06-18 14:08:21.046 4333-22630/? W/System.err:   ... 19 more
06-18 14:08:24.968 402-402/? I/VM_BMS: power_supply_update: ocv_uv=4305482 ibatt=353049 soc=99 seq_num=53788
06-18 14:08:25.784 1572-2844/? W/ActivityManager: Activity destroy timeout for ActivityRecord{94aaab2 u0 com.example.user.appsightseeing/.DetailActivity t80 f}
06-18 14:08:25.788 1572-2844/? W/ActivityManager: Activity destroy timeout for ActivityRecord{607fa05 u0 com.example.user.appsightseeing/.MainActivity t80 f}
06-18 14:08:29.073 4333-22623/? W/System.err: java.net.UnknownHostException: Unable to resolve host "www.google.com": No address associated with hostname
06-18 14:08:29.074 4333-22623/? W/System.err:     at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:125)
06-18 14:08:29.074 4333-22623/? W/System.err:     at java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:74)
06-18 14:08:29.074 4333-22623/? W/System.err:     at java.net.InetAddress.getAllByName(InetAddress.java:752)
06-18 14:08:29.074 4333-22623/? W/System.err:     at com.android.okhttp.internal.Network$1.resolveInetAddresses(Network.java:29)
06-18 14:08:29.074 4333-22623/? W/System.err:     at com.android.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:187)
06-18 14:08:29.074 4333-22623/? W/System.err:     at com.android.okhttp.internal.http.RouteSelector.nextProxy(RouteSelector.java:156)
06-18 14:08:29.074 4333-22623/? W/System.err:     at com.android.okhttp.internal.http.RouteSelector.next(RouteSelector.java:98)
06-18 14:08:29.074 4333-22623/? W/System.err:     at com.android.okhttp.internal.http.HttpEngine.createNextConnection(HttpEngine.java:345)
06-18 14:08:29.074 4333-22623/? W/System.err:     at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:328)
06-18 14:08:29.074 4333-22623/? W/System.err:     at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:246)
06-18 14:08:29.074 4333-22623/? W/System.err:     at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:457)
06-18 14:08:29.074 4333-22623/? W/System.err:     at com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:126)
06-18 14:08:29.074 4333-22623/? W/System.err:     at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:257)
06-18 14:08:29.074 4333-22623/? W/System.err:     at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getOutputStream(DelegatingHttpsURLConnection.java:218)
06-18 14:08:29.074 4333-22623/? W/System.err:     at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java)
06-18 14:08:29.075 4333-22623/? W/System.err:     at anwh.a(:com.google.android.gms:87)
06-18 14:08:29.075 4333-22623/? W/System.err:     at apwg.run(:com.google.android.gms:287)
06-18 14:08:29.075 4333-22623/? W/System.err:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
06-18 14:08:29.075 4333-22623/? W/System.err:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
06-18 14:08:29.075 4333-22623/? W/System.err:     at java.lang.Thread.run(Thread.java:761)
06-18 14:08:29.075 4333-22623/? W/System.err: Caused by: android.system.GaiException: android_getaddrinfo failed: EAI_NODATA (No address associated with hostname)
06-18 14:08:29.075 4333-22623/? W/System.err:     at libcore.io.Posix.android_getaddrinfo(Native Method)
06-18 14:08:29.075 4333-22623/? W/System.err:     at libcore.io.ForwardingOs.android_getaddrinfo(ForwardingOs.java:55)
06-18 14:08:29.075 4333-22623/? W/System.err:     at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:106)
06-18 14:08:29.075 4333-22623/? W/System.err:   ... 19 more
06-18 14:08:30.051 290-485/? D/hardware_info: hw_info_append_hw_type : device_name = speaker
06-18 14:08:30.055 290-485/? W/audio_hw_utils: audio_extn_utils_update_stream_app_type_cfg: App type could not be selected. Falling back to default
06-18 14:08:30.055 290-485/? D/ACDB-LOADER: ACDB -> send_audio_cal, acdb_id = 14, path =  0
06-18 14:08:30.055 290-485/? D/ACDB-LOADER: ACDB -> send_asm_topology
06-18 14:08:30.055 290-485/? D/ACDB-LOADER: ACDB -> ACDB_CMD_GET_AUDPROC_STREAM_TOPOLOGY_ID
06-18 14:08:30.055 290-485/? D/ACDB-LOADER: ACDB -> send_adm_topology
06-18 14:08:30.055 290-485/? D/ACDB-LOADER: ACDB -> ACDB_CMD_GET_AUDPROC_COMMON_TOPOLOGY_ID
06-18 14:08:30.055 290-485/? D/ACDB-LOADER: ACDB -> send_audtable
06-18 14:08:30.055 290-485/? D/ACDB-LOADER: ACDB -> ACDB_CMD_GET_AUDPROC_COMMON_TABLE
06-18 14:08:30.055 290-485/? D/ACDB-LOADER: ACDB -> AUDIO_SET_AUDPROC_CAL
06-18 14:08:30.055 290-485/? D/ACDB-LOADER: ACDB -> send_audvoltable
06-18 14:08:30.055 290-485/? D/ACDB-LOADER: ACDB -> ACDB_CMD_GET_AUDPROC_GAIN_DEP_STEP_TABLE
06-18 14:08:30.055 290-485/? D/ACDB-LOADER: ACDB -> AUDIO_SET_AUDPROC_VOL_CAL
06-18 14:08:30.055 290-485/? D/ACDB-LOADER: ACDB -> send_afe_cal
06-18 14:08:30.055 290-485/? D/ACDB-LOADER: ACDB -> ACDB_CMD_GET_AFE_COMMON_TABLE
06-18 14:08:30.055 290-485/? D/ACDB-LOADER: ACDB -> AUDIO_SET_AFE_CAL
06-18 14:08:30.055 290-485/? D/ACDB-LOADER: ACDB -> send_hw_delay : acdb_id = 14 path = 0
06-18 14:08:30.055 290-485/? D/ACDB-LOADER: ACDB -> ACDB_AVSYNC_INFO: ACDB_CMD_GET_DEVICE_PROPERTY
06-18 14:08:30.056 290-485/? I/audio_hw_utils: audio_extn_utils_send_app_type_cfg app_type 69936, acdb_dev_id 14, sample_rate 48000
06-18 14:08:30.154 1572-4878/? I/ActivityManager: Killing 22582:com.example.user.appsightseeing/u0a90 (adj 900): crash
06-18 14:08:30.154 1572-4878/? D/ActivityManager: cleanUpApplicationRecord -- 22582
06-18 14:08:30.155 1572-3092/? I/ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.HOME] flg=0x10200000 cmp=com.google.android.googlequicksearchbox/com.google.android.launcher.GEL (has extras)} from uid 1000 on display 0
06-18 14:08:30.163 7769-7769/? I/GEL: handleIntent(Intent { act=android.intent.action.MAIN cat=[android.intent.category.HOME] flg=0x10200000 cmp=com.google.android.googlequicksearchbox/com.google.android.launcher.GEL (has extras) })
06-18 14:08:30.282 6993-7006/? I/AttachedClient: Adding client event 2 to pending list.
06-18 14:08:30.323 6993-6993/? I/OptInState: There is a new client and it does not support opt-in. Dropping request.
06-18 14:08:30.329 6993-6993/? I/MicroDetectionWorker: Micro detection mode: [mDetectionMode: [1]].
06-18 14:08:30.342 6993-22638/? I/MicroRecognitionRunner: Starting detection.
06-18 14:08:30.344 6993-22604/? I/MicrophoneInputStream: mic_starting com.google.android.apps.gsa.speech.audio.ae@a7225ae
06-18 14:08:30.349 290-22640/? I/AudioFlinger: AudioFlinger's thread 0xa6103040 ready to run
06-18 14:08:30.359 290-22640/? D/hardware_info: hw_info_append_hw_type : device_name = voice-rec-mic
06-18 14:08:30.361 290-22640/? D/ACDB-LOADER: ACDB -> send_audio_cal, acdb_id = 4, path =  1
06-18 14:08:30.361 290-22640/? D/ACDB-LOADER: ACDB -> send_asm_topology
06-18 14:08:30.361 290-22640/? D/ACDB-LOADER: ACDB -> ACDB_CMD_GET_AUDPROC_STREAM_TOPOLOGY_ID
06-18 14:08:30.361 290-22640/? D/ACDB-LOADER: ACDB -> send_adm_topology
06-18 14:08:30.361 290-22640/? D/ACDB-LOADER: ACDB -> ACDB_CMD_GET_AUDPROC_COMMON_TOPOLOGY_ID
06-18 14:08:30.361 290-22640/? D/ACDB-LOADER: ACDB -> send_audtable
06-18 14:08:30.361 290-22640/? D/ACDB-LOADER: ACDB -> ACDB_CMD_GET_AUDPROC_COMMON_TABLE
06-18 14:08:30.361 290-22640/? D/ACDB-LOADER: ACDB -> AUDIO_SET_AUDPROC_CAL
06-18 14:08:30.361 290-22640/? D/ACDB-LOADER: ACDB -> send_audvoltable
06-18 14:08:30.361 290-22640/? D/ACDB-LOADER: ACDB -> ACDB_CMD_GET_AUDPROC_GAIN_DEP_STEP_TABLE

1 个答案:

答案 0 :(得分:0)

您在一个活动中有cell.myTextFielThatIWantToFieldWhenButtonTapped ,但在另一个活动中没有。

这让我相信您使用的是没有工具栏的Activity主题,在这种情况下mToolbar会抛出NullPointerException,您需要先设置工具栏才能使用

将单个字段投入Intent非常容易出错。

使用Parcelable或Serializable对象

How to pass an object from one activity to another on Android