我为所有活动实现了一个后退按钮,除了MainActivity.我的问题是我也有一个后退按钮MainActivity.
希望我已经导入了正确的课程:
import android.support.v4.app.NavUtils;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getActionBar().setDisplayHomeAsUpEnabled(true);
[...]
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
switch (item.getItemId()) {
case android.R.id.home:
NavUtils.navigateUpFromSameTask(this);
return true;
case R.id.ueber:
startActivity(new Intent(this, menu_main_Activity.class));
return true;
}
return super.onOptionsItemSelected(item);
}
Run Code Online (Sandbox Code Playgroud)
AndroidManifest:
<application
android:allowBackup="true" …Run Code Online (Sandbox Code Playgroud) 我在StackOverFlow上搜索了很多有关此问题的内容,但是这些线程的使用时间已超过3年。
我实现了Google Voice Recognition,需要Internet连接。搜索如何使用我Offline Voice Recognition不会带来成功。
现在可以Voice Recognition离线使用吗?
我的代码到目前为止:
speechStartButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
promtSpeechInput();
}
});
private void promtSpeechInput() {
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault());
intent.putExtra(RecognizerIntent.EXTRA_PROMPT,
"Recording...");
try {
startActivityForResult(intent, REQ_CODE_SPEECH_INPUT);
} catch (ActivityNotFoundException e) {
Toast.makeText(getApplicationContext(), "Language not supported", Toast.LENGTH_SHORT).show();
}
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case CAMERA_PIC_REQUEST: {
try {
Bitmap image …Run Code Online (Sandbox Code Playgroud) 我用过很多次了openFileOutput.
例:
FileOutputStream fileOutputStream = openFileOutput(fileName, Context.MODE_PRIVATE);
Run Code Online (Sandbox Code Playgroud)
现在我注意到所有使用openFileOutput方法的文件都将放在私有app files目录中.
看起来像:
/data/data/com.my.app.app/files/example.txt
如何替换此方法以存储子目录上的Files?
例:
/data/data/com.my.app.app/files/subdirectory/example.txt
我想在的右上方绘制一个三角形RelativeLayout。
我triangle.xml使用以下代码创建了一个:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<rotate
android:fromDegrees="45"
android:toDegrees="45"
android:pivotX="-40%"
android:pivotY="87%" >
<shape
android:shape="rectangle" >
<stroke android:color="@color/darkblue" android:width="10dp"/>
<solid
android:color="@color/blue" />
</shape>
</rotate>
</item>
</layer-list>
Run Code Online (Sandbox Code Playgroud)
并遵循本文:
https://looksok.wordpress.com/2013/08/24/android-triangle-arrow-defined-as-an-xml-shape/
问题是我使用三角形作为背景 RelativeLayout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RelativeLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="7dp">
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="false"
android:layout_alignParentRight="false"
android:layout_marginTop="5dp">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="80dp"
android:layout_marginTop="0dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:id="@+id/taskTitle"
android:text="title"
android:layout_gravity="left"
android:textSize="15sp"
android:textStyle="bold" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:paddingBottom="5sp">
<TextView …Run Code Online (Sandbox Code Playgroud) 我想计算两个日期之间的差异.
我有类似的东西:
String deadline = "2015-08-15";
Run Code Online (Sandbox Code Playgroud)
我得到当前的日期:
String timeStamp = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()).format(new Date());
Run Code Online (Sandbox Code Playgroud)
例如,它将是今天:
2015年11月11日
如何计算这两个日期之间的天数?如果日期过去会发生什么.
我有这个 ArrayList
public ArrayList<HashMap<String, String>> xmlFileNames = new ArrayList<>();
Run Code Online (Sandbox Code Playgroud)
我想将其转换为:
HashMap<String, String> comparemap2 = new HashMap<>();
Run Code Online (Sandbox Code Playgroud)
我想要的是:我想要ArrayList中的所有Items并希望将它们放入HashMap我的HashMap看起来像:
核心价值
job_id 032014091029309130921.xml
job_id 201302149014021492929.xml
job_id 203921904901920952099.xml
编辑: 稍后我想将此地图与现有地图进行比较:
Properties properties = new Properties();
try {
properties.load(openFileInput("comparexml.kx_todo"));
} catch (IOException e) {
e.printStackTrace();
}
for (String key : properties.stringPropertyNames()) {
compareMap.put(key, properties.get(key).toString());
}
HashMap<String, String> oldCompareMap = new HashMap<>();
for (HashMap key : xmlFileNames) {
oldCompareMap.putAll(key);
}
isEqualMaps(oldCompareMap, compareMap);
Run Code Online (Sandbox Code Playgroud)
我只想比较,如果文件名存在于compareMap.如果没有,请将其添加到xmlFileName地图中
我已经在StackOverFlow中查找了,我如何将ArrayList转换为HashMap.但是其他线程会将数据类型视为Item或Product.
我希望你能帮帮我!
亲切的问候