게시판 즐겨찾기
편집
드래그 앤 드롭으로
즐겨찾기 아이콘 위치 수정이 가능합니다.
안드로이드 한글 깨짐
게시물ID : programmer_10892짧은주소 복사하기
작성자 : andgate
추천 : 0
조회수 : 379회
댓글수 : 0개
등록시간 : 2015/06/05 19:43:02

public class Tab1 extends Fragment {
Context mContext;

public Tab1(Context context) {
mContext = context;
}
private TextSwitcher mSwitcher;
Button button1;

// Array of String to Show In TextSwitcher
String textToShow[]={"Apple","사과","banana","바나나","Window","창문"};
int messageCount=textToShow.length;
// to keep current Index of text
int currentIndex=-1;

@Override
public View onCreateView(LayoutInflater inflater,
ViewGroup container,Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.activity_tab1, null);
super.onCreate(savedInstanceState);


// get The references
button1 = (Button) view.findViewById(R.id.button1);
mSwitcher = (TextSwitcher) view.findViewById(R.id.textSwitcher);
mSwitcher.setFactory(new ViewSwitcher.ViewFactory() {
@Override
public View makeView() {
TextView myText = new TextView(getActivity());
//new TextView(MainActivity.this);
myText.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL);
myText.setTextSize(36);
return myText;
}
});

button1.setOnClickListener(new View.OnClickListener() {

public void onClick(View v) {
// TODO Auto-generated method stub
currentIndex++;
// If index reaches maximum reset it
if (currentIndex == messageCount)
currentIndex = 0;
mSwitcher.setText(textToShow[currentIndex]);
}
});
return view;
}
}
전체 추천리스트 보기
새로운 댓글이 없습니다.
새로운 댓글 확인하기
글쓰기
◀뒤로가기
PC버전
맨위로▲
공지 운영 자료창고 청소년보호