0
我试图通过xml来实现这一点,而不是尝试失败。我已经尝试创建两个按钮,并通过ViewId调用它们,但随后它们不会显示在UI上,因为它们是自定义按钮。我怎么去解决它?什么是Android的以下java代码的xml等价物?
LinearLayout ll = new LinearLayout(this);
recButton = new CustomRecordButton(this);
ll.addView(recButton,
new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.WRAP_CONTENT,0));
playButton = new CustomPlayButton(this);
ll.addView(playButton, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT,0));
setContentView(ll);
所以,如果我的包被命名为包com.example.assignment22_audio_playback; 我会写
Ceelos
2013-04-23 20:39:21
是的,当然CustomPlayButton扩展按钮 – Benoit 2013-04-23 20:43:40
我试过了,但它不断给我类没有发现错误,当我通过图形查看它时,我也查找了类似的例子,但无法让它工作。无法找到以下类: - com.example.assignment22_audio_playback.CustomPlayButton(修复构建路径,编辑XML,创建类)。这是什么图形显示读取 – Ceelos 2013-04-23 20:46:30