2017-03-05 3 views
0
// I was making swipe Tabs in android Studio i got a error 
// i cannot paste all the code please follow this link to see more information 
https://www.youtube.com/watch?v=VVahIc8yENk 

나는 또한 오류를 가지고 어떤 오류가하는 곳이오류가

package com.example.rahul.swipetabs;  

import android.support.v4.app.FragmentActivity;  
import android.os.Bundle;  
import android.app.ActionBar; 

public class MainActivity extends FragmentActivity { 

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

     mActionBar = getActionBar();   

     mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); 
     //error #1 
     mActionBar.Tab tab1 = mActionBar.newTab(); 
     //error #2 
     // i had explain all the errors below    
    } 
} 

mActionBar를 참조하시기 바랍니다 언급. setNavigationMode (ActionBar. NAVIGATION_MODE_TABS );

//error #1 : Here set Navigation mode & NAVIGATION_MODE_TABS is depreciated 
// How can i solve this problem if it is depreciated 
//can i still use this if it is depreciated  

//mActionBar.Tab tab1 = mActionBar.newTab(); 

//error #2 : "Tab" in code says that Tab cannot resolve symbol 
+0

"감가 상각되는 경우에도 계속 사용할 수 있습니까?"- 잠시 동안 예. 이상적으로, 당신은 다른 것을 사용합니다. 'TabLayout','PagerTabStrip', 써드 파티 탭 표시기 라이브러리 등 많은 방법으로 안드로이드에서 스 와이프 탭을 만들 수 있습니다. – CommonsWare

답변

0

예, 사용되지 않는 방법을 사용할 수 있습니다. 대신이의

:

 mActionBar.Tab tab1 = mActionBar.newTab(); 

이이

ActionBar.Tab tab1 = mActionBar.newTab(); 
    tab1.setText("Tab 1"); 

에서 추가, 우리는 ActionBar.Tab가 탭 따라서 우리가해야 할 액션 바 클래스의 정적 필드 의미로 호출 할 필요가 객체 이름 대신 클래스 이름을 사용하여 이것을 호출하십시오.

+0

은 코드가 의미하는 것과 그 이유를 설명 할 수 있습니다. 탭 –

+0

@Aliaketh In 이, 우리는 ActionBar.Tab가 ActionBar 클래스의 정적 필드임을 의미합니다. – vicky