我有这个错误,我不知道如何修复它。我尝试添加第三方库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>
答案 0 :(得分:0)
我假设您的问题的标题意味着您收到错误代码28的错误。通过Google搜索我发现this page表示错误代码28表示:
XML声明中没有版本信息。
因此,要修复此错误,只需在布局的第一个标记上方添加以下行:
<?xml version="1.0" encoding="utf-8"?>
希望这有帮助!