您好我正在尝试创建共享意图,可以在通过onOptionsItemSelected选择菜单共享按钮时调用。当我按下分享按钮时,它会调用onOptionsItemSelected但不提供共享选项。你能告诉我这里的错误吗?我有多种方法可以实现,但我想知道为什么这不起作用。
这是代码:
public boolean onCreateOptionsMenu(Menu menu) {
/* Use AppCompatActivity's method getMenuInflater to get a handle on the menu inflater */
MenuInflater inflater = getMenuInflater();
/* Use the inflater's inflate method to inflate our menu layout to this menu */
inflater.inflate(R.menu.detail, menu);
/* Return true so that the menu is displayed in the Toolbar */
//MenuItem menuItem = menu.findItem(R.id.action_share);
//menuItem.setIntent(createShareForecastIntent());
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
String message = "Yes I am here";
// TODO (2) Launch the map when the map menu item is clicked
if( id == R.id.action_share) {
Toast.makeText(this, message, Toast.LENGTH_LONG).show();
item.setIntent(createShareForecastIntent());
return true;
}
return super.onOptionsItemSelected(item);
}
private Intent createShareForecastIntent() {
Intent shareIntent = ShareCompat.IntentBuilder.from(this)
.setType("text/plain")
.setText(mForecast + FORECAST_SHARE_HASHTAG)
.getIntent();
return shareIntent;
}
}
答案 0 :(得分:0)
在您粘贴的代码段中,您忘记致电 -
set /A Count=0
for %%I in (*.txt) do set /A Count=%Count%+1
echo %Count%