나는 Android 프로그래밍에 익숙하지 않으며 실제로 Google Play 스토어 사용자 인터페이스처럼 보이게하는 매우 간단한 응용 프로그램을 작성하는 방법을 배우려고합니다.JSON 데이터 + cardslib android 라이브러리를 사용하여 카드 콘텐츠를 동적으로 채우는 방법
나는 실제로 더 많이 또는 더 적게하고 싶은 것을하고있는 cardslib (https://github.com/gabrielemariotti/cardslib)라고 불리는 매우 멋진 안드로이드 라이브러리를 발견했습니다.
지금 내 질문은 정적 이미지 및 텍스트로드 대신 웹 서비스에서 동적 컨텐츠가있는 카드를 만드는 방법입니다.
/**
* This method builds a simple card
*/
private void initCard() {
//Init an array of Cards
ArrayList<Card> cards = new ArrayList<Card>();
for (int i = 0; i < 200; i++) {
PicassoCard card = new PicassoCard(this.getActivity());
card.setTitle("A simple card loaded with Picasso " + i);
card.setSecondaryTitle("Simple text..." + i);
card.setCount(i);
cards.add(card);
}
CardArrayAdapter mCardArrayAdapter = new CardArrayAdapter(getActivity(), cards);
CardListView listView = (CardListView) getActivity().findViewById(R.id.carddemo_extra_list_picasso);
if (listView != null) {
listView.setAdapter(mCardArrayAdapter);
}
}
지금까지 내가 결과에 따라, 위의 방법이 실제로 1에서 나는이 반복 동적으로 만들 수있는 방법 (200)에 반복 카드의 배열을 구축하고이 프로젝트에있는 샘플 코드에서 이해할 수있는 내 웹 서비스 반환?
내 다음 질문은 추출 된 웹 서비스에서 제목 및 보조 제목의 텍스트를 어떻게 바꿀 수 있습니까?
{"id":1,"sTitle":"First Entry","sSubTitle":"Subtitle
1","sImageURL":"http://img.youtube.com/vi/u4ehZSbrl8k/default.jpg?h\u003d90\u0026w\u003d120\u0026sigh\u003d__eYg-lRy4LMjJGrDlyHy1s9yf--M\u003d"},
{"id":2,"sTitle":"Second Entry","sSubTitle":"Subtitle
2","sImageURL":"http://img.youtube.com/vi/TgVgni8GLqs/default.jpg?h\u003d90\u0026w\u003d120\u0026sigh\u003d__zvGG7fO4LT3ipUXfQPpA0N95Q0w\u003d"},
{"id":3,"sTitle":"Third Entry","sSubTitle":"Subtitle
3","sImageURL":"http://img.youtube.com/vi/pZr6y8RnX10/default.jpg?h\u003d90\u0026w\u003d120\u0026sigh\u003d__7JaAVKoYz9IR3CLgHSb1dGkKYbo\u003d"}
생성 된 각 카드에 위의 웹 서비스의 데이터가 포함되어있는 경우 어떻게해야합니까?
class PicassoCardThumbnail extends CardThumbnail {
public PicassoCardThumbnail(Context context) {
super(context);
}
@Override
public void setupInnerViewElements(ViewGroup parent, View viewImage) {
/*
* If your cardthumbnail uses external library you have to provide how to load the image.
* If your cardthumbnail doesn't use an external library it will use a built-in method
*/
//Here you have to set your image with an external library
//Only for test, use a Resource Id and a Url
//It is just an example !
if (((PicassoCard) getParentCard()).getCount() % 2 == 0) {
Picasso.with(getContext()).setDebugging(true); //only for debug tests
Picasso.with(getContext())
.load("https://plus.google.com/s2/photos/profile/114432517923423045208?sz=96")
.error(R.drawable.ic_error_loadingsmall)
.into((ImageView) viewImage);
} else {
Picasso.with(getContext()).setDebugging(true); //only for debug tests
Picasso.with(getContext())
.load(R.drawable.ic_na_img)
.resize(96, 96)
.into((ImageView) viewImage);
}
/*
viewImage.getLayoutParams().width = 96;
viewImage.getLayoutParams().height = 96;
*/
}
}
어떤 조언이나 도움을 주셔서 감사합니다. 또한 Google (https://android.googlesource.com/platform/frameworks/volley/)의 Volley 프로젝트와 함께이 멋진 라이브러리 (cardslib)를 사용하여 실험하고 있지만 지금은 매우 어려운 형태입니다 ...
누군가가 이미 그 일을 처리했다면 샘플 코드 예제를 공부할 기회를 얻었습니다.