【问题标题】:How could i use the same page with different content我怎么能使用具有不同内容的同一页面
【发布时间】:2013-04-13 07:54:09
【问题描述】:

我需要使用具有不同内容的同一页面

例如:i have clicked Array[name] button it will show the couple of names in listview next when i will click the address array the same activity instead of name can we show the address!!

我已经搜索过,我发现了一些类似的东西

Intent intent = new Intent(context, CalledActivity.class);
        intent.putExtra(key, value);
        startActivity(intent);

这里他们使用 sqlite 数据库来获取内容。有人可以帮助我吗@Thanks

【问题讨论】:

  • 您只想更改内容还是显示的视图(用户界面)?
  • @MehulJoisar yes..更改 ui 中的内容
  • 那么您可以按照 j2emanue 的建议通过分配新适配器轻松更改内容。如果您还有任何疑问,请发布代码以便我们为您提供指导。

标签: android arraylist android-activity


【解决方案1】:

我不明白为什么你不能更新数据然后调用 notifyDataSetChanged() 来更新你的列表视图。

您的适配器可能定义如下:
ArrayAdapter myadapter=new ArrayAdapter(this, android.R.layout.simple_list_item_1, theDataSource1);

然后 theDataSource1=数组名称

所以当点击地址按钮时尝试 theDataSourcd1=数组地址

然后 myadapter.notifyDataSetChanged();

另一种方式,但其糟糕的设计是您可以拥有另一个适配器,然后在单击按钮时更改列表视图的适配器,它们会切换。

【讨论】:

  • k.thanks let me try..which would be better to try another class or adapter
  • 只需将适配器上的数据源更改为更干净。
  • j2emanue 我正在使用相同的适配器获得不同的数组类别我怎么能改变你能举个简单的例子吗
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-09-12
  • 1970-01-01
  • 2022-01-21
  • 1970-01-01
  • 2021-09-17
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多