我有一个使用 ActionBar 选项卡的 FragmentActivity,其中一个选项卡有一个包含一系列图表的选项卡主机。
此活动是通过搜索启动的,因此在加载活动时键盘会消失,这会导致第一个选项卡的图表显示为压缩状态。这只发生在第一次加载活动时。在我的第二次搜索中,图表完整显示。
TabHost 活动如下所示,
[Activity]
public class MonthlySalesChartView : Activity
{
private CustomerRepository _customerRespository;
private BaseChart _chart;
private string _code;
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
_customerRespository = new CustomerRepository();
_chart = BuildChart();
_code = Intent.GetStringExtra("customer_code");
SetContentView(_chart);
}
private BaseChart BuildChart()
{
var data = _customerRespository.GetMonthlySalesData(_code);
var tChart = new BaseChart(ApplicationContext, "Monthly Sales History");
tChart.Axes.Left.Title.Text = "Spend ($)";
tChart.Aspect.View3D = false;
var bar1 = new BaseBar(tChart.Chart) { Title = "Customer Spend" };
bar1.Marks.Visible = false;
var avgLine = new Line(tChart.Chart) { Title = "Average Spend", Dark3D = false, LinePen = { Width = 4 } };
foreach (var month in data.ResultSet.MonthlySales)
{
bar1.Add(month.Value, month.MonthName);
}
avgLine.DataSource = bar1;
avgLine.Function = new Average(true);
avgLine.Depth = 50;
return tChart;
}
}
外观示例