2017-02-11 8 views
0

このエラーがあり、修正方法がわかりません。サードパーティのライブラリXML要素を追加しようとしたときにエラーが発生しましたが、解決できません。エラー:(28)XML解析中にエラーが発生しました:要素が見つかりません

一部の場所では、Android Studioの問題で、プログラムを再起動することで修正されていますが、問題は解決していません。ここでは、コードは次のとおりです。

public class HorizontalNtbActivity extends Activity { 

    @Override 
    protected void onCreate(final Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_horizontal_ntb); 
     initUI(); 
    } 

    private void initUI() { 
     final ViewPager viewPager = (ViewPager) findViewById(R.id.vp_horizontal_ntb); 
     viewPager.setAdapter(new PagerAdapter() { 
      @Override 
      public int getCount() { 
       return 5; 
      } 

      @Override 
      public boolean isViewFromObject(final View view, final Object object) { 
       return view.equals(object); 
      } 

      @Override 
      public void destroyItem(final View container, final int position, final Object object) { 
       ((ViewPager) container).removeView((View) object); 
      } 

      @Override 
      public Object instantiateItem(final ViewGroup container, final int position) { 
       final View view = LayoutInflater.from(
         getBaseContext()).inflate(R.layout.item_vp, null, false); 

       final TextView txtPage = (TextView) view.findViewById(R.id.txt_vp_item_page); 
       txtPage.setText(String.format("Page #%d", position)); 

       container.addView(view); 
       return view; 
      } 
     }); 

     final String[] colors = getResources().getStringArray(R.array.default_preview); 

     final NavigationTabBar navigationTabBar = (NavigationTabBar) findViewById(R.id.ntb_horizontal); 
     final ArrayList<NavigationTabBar.Model> models = new ArrayList<>(); 
     models.add(
       new NavigationTabBar.Model.Builder(
         getResources().getDrawable(R.drawable.ic_first), 
         Color.parseColor(colors[0])) 
         .selectedIcon(getResources().getDrawable(R.drawable.ic_sixth)) 
         .title("Heart") 
         .badgeTitle("NTB") 
         .build() 
     ); 
     ... 
    } 
    .... 
} 

activity_main.xml:

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:background="#423752" 
    android:orientation="vertical"> 

    <android.support.v4.view.ViewPager 
     android:id="@+id/PostList" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1"/> 

    <devlight.io.library.ntb.NavigationTabBar 
     android:id="@+id/ntb_horizontal" 
     android:layout_width="match_parent" 
     android:layout_height="60dp" 
     app:ntb_badge_gravity="top" 
     app:ntb_badge_position="right" 
     app:ntb_badged="true" 
     app:ntb_scaled="true" 
     app:ntb_tinted="true" 
     app:ntb_title_mode="all" 
     app:ntb_titled="true" 
     app:ntb_swiped="true"/> 
    ... 
</LinearLayout> 
+2

デバッグのヘルプを求める質問( '**なぜこのコードは機能していないのですか?**')には、目的の動作、特定の問題またはエラー、およびそれを再現するのに必要な最短コードが**含まれている必要があります** 。 **明確な問題文**のない質問は他の読者には役に立たない。参照:[最小限で完全で検証可能なサンプルの作成方法](http://stackoverflow.com/help/mcve) – Biffen

答えて

0

私はあなたの質問のタイトルを仮定していることは、あなたがこの私のためにグーグルでは、エラーコード28でエラーを取得する意味します発見したエラーコード28を記載this pageがあることを意味します

The version information wasn’t present in the XML declaration.

だからこのエラーを修正するために、単にあなたの最初のタグの上に次の行を追加しますレイアウト:

<?xml version="1.0" encoding="utf-8"?> 

関連する問題