我正在尝试与其他应用程序(例如 twitter、gmail 等)共享翻转视图内容。但是,共享按钮有效,但不显示抽认卡内容,而是显示“android.widget.ViewFlipper@40523fc0”的文本。任何帮助,请我一直在挣扎一段时间。下面是我的 Java 代码。xml 代码仅包含几个按钮和一个文本视图。
public class Jokes extends Activity 实现 OnClickListener, OnTouchListener {
ViewFlipper flippy;
Random r = new Random();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.jokes);
flippy = (ViewFlipper) findViewById(R.id.viewFlipper1);
flippy.setOnClickListener(this);
Button b = (Button) findViewById(R.id.bShare);
b.setOnTouchListener(this);
String s [ ]= {"abc", "DEF", "ghi"};
}
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
int i = r.nextInt();
flippy.setDisplayedChild(r.nextInt(4));
flippy.showNext();
}
@Override
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, ""+ flippy);
startActivity(Intent.createChooser(intent, "Udir/Share"));
return true;
}
}