다른 탭의 데이터를 분류하기 위해 ActionBar Tab Fragment를 사용하는 애플리케이션이 있습니다. 주 활동 (탭 활동)에서 단추를 누를 때 Tab Fragment에서 메소드를 호출해야합니다. 내가 온 클릭에서) 방법을 NetworkFragmentTab의을 유효성 검사를 (전화를 좋아메소드를 호출하는 방법은 ActionBar Tab에 있습니다. 주요 활동의 일부분
public class NetworkFragmentTab extends Fragment {
View rootView;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
rootView = inflater.inflate(R.layout.network_layout, container, false);
return rootView;
}
public boolean Validate(){
EditText etIpAddress = (EditText)rootView.findViewById(R.id.cd_ip_address);
Toast.makeText(getActivity(), etIpAddress.getText().toString(), Toast.LENGTH_LONG).show();
return true;
}
}
NetworkFragment 코드
카메라 세부 활동 아래
public class CameraDetails extends Activity {
ActionBar.Tab networkTab, userTab;
Fragment networkFragmentTab = new NetworkFragmentTab();
Fragment userFragmentTab = new UserFragmentTab();
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.cameradetails);
// Asking for the default ActionBar element that our platform supports.
ActionBar actionBar = getActionBar();
// Screen handling while hiding ActionBar icon.
actionBar.setDisplayShowHomeEnabled(false);
// Screen handling while hiding Actionbar title.
actionBar.setDisplayShowTitleEnabled(false);
// Creating ActionBar tabs.
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
// Setting custom tab icons.
networkTab = actionBar.newTab().setText("Network"); //.setIcon(R.drawable.bmw_logo);
userTab = actionBar.newTab().setText("User Account");
// Setting tab listeners.
networkTab.setTabListener(new TabListener(networkFragmentTab));
userTab.setTabListener(new TabListener(userFragmentTab));
// Adding tabs to the ActionBar.
actionBar.addTab(networkTab);
actionBar.addTab(userTab);
actionBar.setSelectedNavigationItem(1);
}
public void onClick(View v){
// call method validate from NetworkFragment like networkfragment.validate();
}
}
}
을 시도했다.
당신이 오류를 가지고 있습니까? –
@SathishKumarJ 위의 onClick 코드는 각 탭 이름 만 표시합니다. 내 편집 된 질문을 참조하십시오 – Riskhan