ListFragment Grafische Ansicht - HILFE

S

sugg1

Neues Mitglied
0
Hallo,

ich habe ein ListFragment aus einem Youtube Video nachgemacht. Scheinbar liegt das Problem an meinem Grafischen Layout der activity_main.xml:

Im Anhang befindet sich ein Screenshot.

Hier der Quellcode der activity_main.xml:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
tools:ignore="MergeRootFrame" >



<fragment
android:id="@+id/fragment1"
android:name="com.example.dialog_slidenerd.MyListFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />



</FrameLayout>



Ich hoffe hier kann mir jemand helfen :confused2:
 

Anhänge

  • fragment.jpg
    fragment.jpg
    1,2 KB · Aufrufe: 213
Zuletzt bearbeitet:
Wie sieht die .xml Datei von deinem MyListFragment aus?
 
my_list_fragment.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</ListView>



</LinearLayout>

Der ursprüngliche Beitrag von 21:35 Uhr wurde um 21:36 Uhr ergänzt:
und das ist die MyListFragement Klasse:

package com.example.dialog_slidenerd;

import android.app.ListFragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Toast;

public class MyListFragment extends ListFragment implements AdapterView.OnItemClickListener {

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
return inflater.inflate(R.layout.my_list_fragment, container, false);
}

@Override
public void onActivityCreated(Bundle savedInstanceState)
{
super.onActivityCreated(savedInstanceState);
ArrayAdapter adapter = ArrayAdapter.createFromResource(getActivity(), R.array.heroes, android.R.layout.simple_list_item_1);
setListAdapter(adapter);
getListView().setOnItemClickListener(this);
}

@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l)
{
Toast.makeText(getActivity(), "Item " +i, Toast.LENGTH_SHORT).show();
}

}
 
Zuletzt bearbeitet:

Ähnliche Themen

D
Antworten
17
Aufrufe
407
datNeMo
D
R
  • RudolfHagen
Antworten
1
Aufrufe
652
koje71
koje71
R
Antworten
9
Aufrufe
732
koje71
koje71
Zurück
Oben Unten