我正在尝试在create上突出显示主/详细信息流中的listview项。因此,当活动加载时,我想说第二个项目已经突出显示。我怎么能这样做,代码明智?
到目前为止,我已经尝试过这个:
@Override
public void onItemSelected(int id, String value)
{
if (mTwoPane)
{
// In two-pane mode, show the detail view in this activity by
// adding or replacing the detail fragment using a
// fragment transaction.
Bundle arguments = new Bundle();
arguments.putInt("num", id);
((ItemListFragment) getSupportFragmentManager().findFragmentById(R.id.item_list))
.setActivatedPosition(2); //Setting it here
arguments.putString("value", value);
CountingFragment fragment = new CountingFragment();
fragment.setArguments(arguments);
getSupportFragmentManager().beginTransaction().replace(R.id.item_detail_container, fragment).commit();
}
else
{
// In single-pane mode, simply start the detail activity
// for the selected item ID.
Intent detailIntent = new Intent(this, CountingFragment.class);
detailIntent.putExtra("num", id);
detailIntent.putExtra("value", value);
startActivity(detailIntent);
}
}
并且不起作用:(