双11狂欢大促

盲盒赢 定制羽绒服

开启惊喜盲盒,抽取你的专属好礼

— 惊喜奖品抢先看 —

Unfortunately, app name has stopped.

a289339793 a289339793 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
这是logcat里显示的错误信息。
下面是java文件源码
package com.example.dialer;


import android.os.Bundle;
import android.R.string;
import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
import android.text.Selection;
import android.text.Spannable;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.Toast;

public class MainActivity extends Activity {

private EditText et;
private Button btn0, btn1, btn2, btn3, btn4, btn5, btn6, btn7, btn8, btn9;
private Button btn11,btn12;
private LinearLayout llMainView;
private View mView;
private StringBuffer input;
private int length;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

InitView();
}

private void InitView()
{
et = (EditText) findViewById(R.id.tv1);
btn0 = (Button) mView.findViewById(R.id.btn0);
btn1 = (Button) mView.findViewById(R.id.btn1);
btn2 = (Button) mView.findViewById(R.id.btn2);
btn3 = (Button) mView.findViewById(R.id.btn3);
btn4 = (Button) mView.findViewById(R.id.btn4);
btn5 = (Button) mView.findViewById(R.id.btn5);
btn6 = (Button) mView.findViewById(R.id.btn6);
btn7 = (Button) mView.findViewById(R.id.btn7);
btn8 = (Button) mView.findViewById(R.id.btn8);
btn9 = (Button) mView.findViewById(R.id.btn9);
// 数字特殊键
btn11 = (Button) mView.findViewById(R.id.btn11);//变色
btn12 = (Button) mView.findViewById(R.id.btn12);//删除
}


public void onClick(View v)
{
switch (v.getId())
{
case R.id.btn1:
case R.id.btn2:
case R.id.btn3:
case R.id.btn4:
case R.id.btn5:
case R.id.btn6:
case R.id.btn7:
case R.id.btn8:
case R.id.btn9:
toInput((Button) v);
break;
case R.id.btn0:
input = new StringBuffer();
input.append(btn0.getText().toString());
et.setText(input.toString());
break;
case R.id.btn12:
toDelete();
break;
default:
break;
}
// 确定光标的位置在最后边
CharSequence text = et.getText();
Selection.setSelection((Spannable) text, text.length());
}


// 用于长按某一按钮时情况EditText
private void toDelete()
{
length = input.length();
if (length > 0)
{
input = input.deleteCharAt(input.length() - 1);
et.setText(input);
}
}

// 用于点击按钮输入
private void toInput(Button btn)
{
input.append(btn.getText().toString());
et.setText(input.toString());
}

// 长按del键,清空EditText
private OnLongClickListener mListener = new OnLongClickListener()
{

@Override
public boolean onLongClick(View v)
{
int length = input.length();
if (length > 0)
{
input.delete(0, input.length() - 1);
et.setText(input);
}
return false;
}
};

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}

}


我做的是拨号的界面
下面是activity_main.xml的源码
<TableLayout
android:id="@+id/TableLayout01"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
>

<EditText
android:id="@+id/tv1"
android:layout_width="320dip"
android:layout_height="wrap_content"
android:layout_weight="1.00"
android:hint="@string/text"
android:gravity="right"
android:phoneNumber="true"/>

<TableRow android:id="@+id/TableRow01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<Button
android:id="@+id/btn1"
android:layout_width="100dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="myclick"
android:text="@string/btn1" />

<Button
android:id="@+id/btn2"
android:layout_width="100dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="myclick"
android:text="@string/btn2" />

<Button
android:id="@+id/btn3"
android:layout_width="100dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="myclick"
android:text="@string/btn3" />
</TableRow>

<TableRow android:id="@+id/TableRow02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<Button
android:id="@+id/btn4"
android:layout_width="100dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="myclick"
android:text="@string/btn4" />

<Button
android:id="@+id/btn5"
android:layout_width="100dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="myclick"
android:text="@string/btn5" />

<Button
android:id="@+id/btn6"
android:layout_width="100dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="myclick"
android:text="@string/btn6" />
</TableRow>

<TableRow android:id="@+id/TableRow03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<Button
android:id="@+id/btn7"
android:layout_width="100dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="myclick"
android:text="@string/btn7" />

<Button
android:id="@+id/btn8"
android:layout_width="100dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="myclick"
android:text="@string/btn8" />

<Button
android:id="@+id/btn9"
android:layout_width="100dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="myclick"
android:text="@string/btn9" />
</TableRow>

<TableRow android:id="@+id/TableRow04"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<Button
android:id="@+id/btn11"
android:layout_width="100dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="myclick"
android:text="@string/btn11" />

<Button
android:id="@+id/btn0"
android:layout_width="100dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="myclick"
android:text="@string/btn0" />

<Button
android:id="@+id/btn12"
android:layout_width="100dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="myclick"
android:text="@string/btn12" />
</TableRow>




</TableLayout>

跪求大神帮看为什么,我是新手,才学安卓几天。老师布置的作业
...全文

相关推荐

Android代码-CustomActivityOnCrash

Custom Activity On Crash library This library allows launching a custom activity when the app crashes, instead of showing the hated "Unfortunately, X has stopped" dialog. How to use One-step install Add the following dependency to your build.gradle: dependencies { compile 'cat.ereza:customactivityoncrash:2.1.0' } ...and you are done! Of course, you can combine this library with any other crash handler such as Crashlytics, ACRA or Firebase, just set them up as you would normally. Try it Forc

weixin_39840914

genymotion 安装问题+虚拟机安装+配置全套完美解决

1. genymotion unfortunately has stopped , 完美解决。 2. 解决genymotion-arm-translation.zip无法拖拽安装的完美问题。 4. genymotion,拖进去后变成Files successfully copied to: /sdcard/Download, 完美解决。 4.genmotion无法查找的ADB设备问题 完美解决。 5.Genymotion安装安卓app,产生 An error occured while deploying the file. This probably means that the app c

qq_41992277

工业互联网工控安全与工业质检AI大模型建设方案.pptx

工业互联网工控安全与工业质检AI大模型建设方案.pptx

公众号:优享智库

2024 《计算机网络》实验教学指导书.doc

2024 《计算机网络》实验教学指导书.doc

2601_96209082

不平衡电网下自抗扰顺序模型预测PWM整流器控制仿真模型(Simulink仿真实现)

内容概要:本文围绕面向城市空中交通的多无人机路径规划问题展开研究,提出了一套融合全局规划、动态避障与局部协同调整的综合路径规划方法。研究内容涵盖基于改进RRT算法与图论的全局路径规划、基于动态风险场和动态窗口法(DWA)的模型预测控制实现动态避障,以及基于分布式协同控制的多无人机局部路径协同策略。通过Matlab平台构建仿真环境,在多种典型城市交通场景下对所提方法进行了系统性验证,结果表明该方法在路径安全性、编队稳定性与任务效率方面表现优异。文章还深入探讨了算法的创新点与未来研究方向,为复杂城市环境下多无人机系统的自主协同提供了理论支撑与技术路径。; 适合人群:具备自动化、控制理论、计算机科学或相关领域基础知识,从事无人机系统、智能交通、路径规划、多智能体协同控制等方向研究的研究生、科研人员及工程技术人员。; 使用场景及目标:①为城市空中交通系统中的多无人机安全、高效飞行提供可靠的路径规划解决方案;②支持在复杂、动态的城市场景中开展无人机自主导航、编队飞行与协同控制的技术研究与仿真验证。; 阅读建议:建议结合提供的Matlab代码进行实践操作,重点关注算法的具体实现细节、参数配置对性能的影响以及不同仿真场景下的实验设计,以深入理解各模块的集成逻辑与实际应用效果。

稷下科研社
评论 6
收藏 已收藏
分享
返回顶部
a289339793
Android 80,489 成员 91,375 内容