我是Android的新手,我正在尝试开发应该显示位于drawable文件夹中的图像的应用程序,如图所示:
请提供有关如何实现此效果的建议。还提供一些适当的链接和解释代码将受到高度赞赏...
答案 0 :(得分:0)
JAVA CODE
/****
* The Class CoverFlowTestingActivity.
*/
public class CoverFlowTestingActivity extends Activity {
private TextView textView;
/*
* (non-Javadoc)
*
* @see android.app.Activity#onCreate(android.os.Bundle)
*/
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
textView = (TextView) findViewById(this.getResources()
.getIdentifier("statusText", "id", "pl.polidea.coverflow"));
// note resources below are taken using getIdentifier to allow importing
// this library as library.
final CoverFlow coverFlow1 = (CoverFlow) findViewById(this.getResources().getIdentifier("coverflow", "id",
"pl.polidea.coverflow"));
setupCoverFlow(coverFlow1, false);
final CoverFlow reflectingCoverFlow = (CoverFlow) findViewById(this.getResources().getIdentifier(
"coverflowReflect", "id", "pl.polidea.coverflow"));
setupCoverFlow(reflectingCoverFlow, true);
}
/**
* Setup cover flow.
*
* @param mCoverFlow
* the m cover flow
* @param reflect
* the reflect
*/
private void setupCoverFlow(final CoverFlow mCoverFlow, final boolean reflect) {
BaseAdapter coverImageAdapter;
if (reflect) {
coverImageAdapter = new ReflectingImageAdapter(new ResourceImageAdapter(this));
} else {
coverImageAdapter = new ResourceImageAdapter(this);
}
mCoverFlow.setAdapter(coverImageAdapter);
mCoverFlow.setSelection(2, true);
setupListeners(mCoverFlow);
}
/**
* Sets the up listeners.
*
* @param mCoverFlow
* the new up listeners
*/
private void setupListeners(final CoverFlow mCoverFlow) {
mCoverFlow.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(final AdapterView< ? > parent, final View view, final int position, final long id) {
textView.setText("Item clicked! : " + id);
}
});
mCoverFlow.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(final AdapterView< ? > parent, final View view, final int position, final long id) {
textView.setText("Item selected! : " + id);
}
@Override
public void onNothingSelected(final AdapterView< ? > parent) {
textView.setText("Nothing clicked!");
}
});
}
}
<强> XML 强>
<?xml version="1.0" encoding="utf-8"?>
<pl.polidea.coverflow.CoverFlow
xmlns:coverflow="http://schemas.android.com/apk/res/pl.polidea.coverflow"
coverflow:imageWidth="100dip" coverflow:imageHeight="150dip" coverflow:withReflection="true"
coverflow:imageReflectionRatio="0.2" coverflow:reflectionGap="2dip"
android:id="@+id/coverflowReflect"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_marginTop="5dip" />
<TextView android:text="STATUS" android:layout_width="fill_parent" android:layout_height="wrap_content"
android:padding="5dip" android:id="@+id/statusText"></TextView>