2017-04-22 10 views
1

: 2リストビュー、 2のTextView、 2 mapfragments、 私はadatperを使用して最初のリストビューに[]私の文字列をロードしようとしたとき、私は奇妙なエラーが発生しています。どんな提案が間違っていますか?私はこの問題がリストビューとアダプターのためだと確信しています。私はそれを削除し、アダプタなしで活動を開始すると、レイアウトはOKをロードしています。Androidの二つのリストビューとアダプタ

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout android:id="@+id/LLglowny" 
       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:orientation="horizontal" 
       android:weightSum="1" 
       tools:context="com.example.norbert.routespreparation2.DistanceAdvisor"> 

    <LinearLayout 
     android:id="@+id/LLtrasa1" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_weight="0.5" 
     android:orientation="vertical"> 

     <TextView 
      android:id="@+id/TvInfoTrasa1" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:text="TEST"/> 

     <ListView 
      android:id="@+id/LvTrasa1" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_weight="0.5"> 


     </ListView> 


     <fragment android:id="@+id/map1" 
        class="com.google.android.gms.maps.SupportMapFragment" 
        xmlns:android="http://schemas.android.com/apk/res/android" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:layout_weight="0.5"> 


     </fragment> 


    </LinearLayout> 

    <LinearLayout 
     android:id="@+id/LLtrasa2" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_weight="0.5" 
     android:orientation="vertical" 
     android:weightSum="1"> 

     <TextView 
      android:id="@+id/TvInfoTrasa2" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 

      android:text="TEST"/> 

     <ListView 
      android:id="@+id/LvTrasa2" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_weight="0.5"> 
     </ListView> 

     <fragment 

      android:id="@+id/map2" 
      android:name="com.google.android.gms.maps.SupportMapFragment" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_weight="0.5"> 


     </fragment> 


    </LinearLayout> 


</LinearLayout> 

とクラスコード:

public class DistanceAdvisor extends AppCompatActivity implements OnMapReadyCallback { 

    @BindView(R.id.LvTrasa1) 
    ListView LvTrasa1; 
    @BindView(R.id.LvTrasa2) 
    ListView LvTrasa2; 
    @BindView(R.id.LLtrasa1) 
    LinearLayout LLtrasy; 
    @BindView(R.id.LLglowny) 
    LinearLayout LLglowny; 
    @BindView(R.id.TvInfoTrasa1) 
    TextView TvInfoTrasa1; 
    @BindView(R.id.TvInfoTrasa2) 
    TextView TvInfoTrasa2; 

    private GoogleMap map1, map2; 
    private int ItemClickedPosition; 
    private DatabaseHelper databaseHelper; 
    private Cursor data; 
    private String[] tablicaAdresow; 

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

     ButterKnife.bind(this); 
     SupportMapFragment supportMapFragment1 = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map1); 
     SupportMapFragment supportMapFragment2 = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map2); 

     supportMapFragment1.getMapAsync(this); 
     supportMapFragment2.getMapAsync(this); 

     Bundle b = getIntent().getExtras(); 
     ItemClickedPosition = b.getInt("ItemClicked", 0); 


     databaseHelper = new DatabaseHelper(this); 
     data = databaseHelper.getData(); 
     tablicaAdresow = new String[100000]; 

     StworzTabliceAdresow(); 

     ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,R.layout.activity_distance_advisor, R.id.LvTrasa1, tablicaAdresow); 
     LvTrasa1.setAdapter(adapter); 
    } 

    private void StworzTabliceAdresow() { 
     String stringAdresow; 
     data.moveToPosition(ItemClickedPosition); 
     stringAdresow = data.getString(4); 

     tablicaAdresow = stringAdresow.split(Pattern.quote("|")); 
     Log.d("pokaz", String.valueOf(tablicaAdresow.length)); 

    } 

    @Override 
    public void onMapReady(GoogleMap googleMap) { 
     map1 = googleMap; 
     map2 = googleMap; 
    } 
} 

とエラーログ:

FATAL EXCEPTION: main 
                         Process: com.example.norbert.routespreparation2, PID: 7764 
                         android.view.InflateException: Binary XML file line #34: Error inflating class fragment 
                          at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:763) 
                          at android.view.LayoutInflater.rInflate(LayoutInflater.java:806) 
                          at android.view.LayoutInflater.rInflate(LayoutInflater.java:809) 
                          at android.view.LayoutInflater.inflate(LayoutInflater.java:504) 
                          at android.view.LayoutInflater.inflate(LayoutInflater.java:414) 
                          at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:371) 
                          at android.widget.ArrayAdapter.getView(ArrayAdapter.java:362) 
                          at android.widget.AbsListView.obtainView(AbsListView.java:2347) 
                          at android.widget.ListView.makeAndAddView(ListView.java:1864) 
                          at android.widget.ListView.fillDown(ListView.java:698) 
                          at android.widget.ListView.fillFromTop(ListView.java:759) 
                          at android.widget.ListView.layoutChildren(ListView.java:1673) 
                          at android.widget.AbsListView.onLayout(AbsListView.java:2151) 
                          at android.view.View.layout(View.java:15671) 
                          at android.view.ViewGroup.layout(ViewGroup.java:5038) 
                          at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1703) 
                          at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1557) 
                          at android.widget.LinearLayout.onLayout(LinearLayout.java:1466) 
                          at android.view.View.layout(View.java:15671) 
                          at android.view.ViewGroup.layout(ViewGroup.java:5038) 
                          at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1703) 
                          at android.widget.LinearLayout.layoutHorizontal(LinearLayout.java:1692) 
                          at android.widget.LinearLayout.onLayout(LinearLayout.java:1468) 
                          at android.view.View.layout(View.java:15671) 
                          at android.view.ViewGroup.layout(ViewGroup.java:5038) 
                          at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579) 
                          at android.widget.FrameLayout.onLayout(FrameLayout.java:514) 
                          at android.view.View.layout(View.java:15671) 
                          at android.view.ViewGroup.layout(ViewGroup.java:5038) 
                          at android.support.v7.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java:437) 
                          at android.view.View.layout(View.java:15671) 
                          at android.view.ViewGroup.layout(ViewGroup.java:5038) 
                          at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579) 
                          at android.widget.FrameLayout.onLayout(FrameLayout.java:514) 
                          at android.view.View.layout(View.java:15671) 
                          at android.view.ViewGroup.layout(ViewGroup.java:5038) 
                          at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1703) 
                          at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1557) 
                          at android.widget.LinearLayout.onLayout(LinearLayout.java:1466) 
                          at android.view.View.layout(View.java:15671) 
                          at android.view.ViewGroup.layout(ViewGroup.java:5038) 
                          at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579) 
                          at android.widget.FrameLayout.onLayout(FrameLayout.java:514) 
                          at android.view.View.layout(View.java:15671) 
                          at android.view.ViewGroup.layout(ViewGroup.java:5038) 
                          at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2086) 
                          at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1843) 
                          at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1061) 
                          at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5885) 
                          at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767) 
                          at android.view.Choreographer.doCallbacks(Choreographer.java:580) 
                          at android.view.Choreographer.doFrame(Choreographer.java:550) 
                          at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753) 
                          at android.os.Handler.handleCallback(Handler.java:739) 
                          at android.os.Handler.dispatchMessage(Handler.java:95) 
                          at android.os.Looper.loop(Looper.java:135) 
                          at android.app.ActivityThread.main(ActivityThread.java:5254) 
                          at java.lang.reflect.Method.invoke(Native Method) 
                          at java.lang.reflect.Method.invoke(Method.java:372) 
                          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) 
                          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) 
                         Caused by: java.lang.IllegalArgumentException: Binary XML file line #34: Duplicate id 0x 
+0

を助け、非常に簡単です。そこに印刷されたログを投稿できますか? –

+0

04-22 15:09:40.126 3383-3383/com.example.norbert.routespreparation2 D/pokaz:6は、取得したいデータを正しく取得します。 –

答えて

0

それは愚かだが、私はTextViewの持つ単一の行レイアウトを作成するのを忘れ。 たとえば、id行のTextViewを含むid行sLineLayoutの単一行レイアウトを作成する場合、ArrayAdapterの初期化は次のようになります。 ArrayAdapter adapter = new ArrayAdapter(this、R.layout.sLineLayout、R.id.row、tab );

それは私が問題は `StworzTabliceAdresow()`メソッドであると思います多分それは誰か:)

関連する問題