- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在我的textview的mainactivity中添加了onClick,我没有错误,但是当我运行应用程序时,它崩溃说应用程序已停止工作,即使我的代码中没有错误,我不知道问题是什么
我希望你能帮助我并提前致谢
这是我的日志猫
12-25 03:32:44.694: I/Ads(1433): AdLoader timed out after 60000ms while getting the URL.
12-25 03:33:00.234: I/Process(1433): Sending signal. PID: 1433 SIG: 9
12-25 03:33:38.454: D/dalvikvm(1559): GC_FOR_ALLOC freed 40K, 4% free 3135K/3248K, paused 283ms, total 286ms
12-25 03:33:38.504: I/dalvikvm-heap(1559): Grow heap (frag case) to 4.200MB for 1127536-byte allocation
12-25 03:33:38.654: D/dalvikvm(1559): GC_FOR_ALLOC freed 2K, 3% free 4233K/4352K, paused 146ms, total 146ms
12-25 03:33:39.144: D/dalvikvm(1559): GC_FOR_ALLOC freed <1K, 3% free 4238K/4352K, paused 46ms, total 47ms
12-25 03:33:39.304: I/dalvikvm-heap(1559): Grow heap (frag case) to 9.535MB for 5591056-byte allocation
12-25 03:33:39.394: D/dalvikvm(1559): GC_FOR_ALLOC freed <1K, 2% free 9698K/9816K, paused 84ms, total 84ms
12-25 03:33:40.284: V/WebViewChromium(1559): Binding Chromium to the background looper Looper (main, tid 1) {b1d56e50}
12-25 03:33:40.304: I/chromium(1559): [INFO:library_loader_hooks.cc(112)] Chromium logging enabled: level = 0, default verbosity = 0
12-25 03:33:40.334: I/BrowserProcessMain(1559): Initializing chromium process, renderers=0
12-25 03:33:40.514: D/(1559): HostConnection::get() New Host Connection established 0xb7a714f8, tid 1559
12-25 03:33:40.594: W/chromium(1559): [WARNING:proxy_service.cc(888)] PAC support disabled because there is no system implementation
12-25 03:33:41.664: E/ActivityThread(1559): Failed to find provider info for com.google.plus.platform
12-25 03:33:41.774: I/Ads(1559): To get test ads on this device, call adRequest.addTestDevice(AdRequest.TEST_EMULATOR);
12-25 03:33:42.194: D/AndroidRuntime(1559): Shutting down VM
12-25 03:33:42.194: W/dalvikvm(1559): threadid=1: thread exiting with uncaught exception (group=0xb1a83ba8)
12-25 03:33:42.214: E/AndroidRuntime(1559): FATAL EXCEPTION: main
12-25 03:33:42.214: E/AndroidRuntime(1559): Process: imamalsajadsayings.android.com, PID: 1559
12-25 03:33:42.214: E/AndroidRuntime(1559): java.lang.RuntimeException: Unable to start activity ComponentInfo{imamalsajadsayings.android.com/imamalsajadsayings.android.com.MainActivity}: java.lang.ClassCastException: android.widget.TextView cannot be cast to android.widget.LinearLayout
12-25 03:33:42.214: E/AndroidRuntime(1559): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
12-25 03:33:42.214: E/AndroidRuntime(1559): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
12-25 03:33:42.214: E/AndroidRuntime(1559): at android.app.ActivityThread.access$800(ActivityThread.java:135)
12-25 03:33:42.214: E/AndroidRuntime(1559): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
12-25 03:33:42.214: E/AndroidRuntime(1559): at android.os.Handler.dispatchMessage(Handler.java:102)
12-25 03:33:42.214: E/AndroidRuntime(1559): at android.os.Looper.loop(Looper.java:136)
12-25 03:33:42.214: E/AndroidRuntime(1559): at android.app.ActivityThread.main(ActivityThread.java:5017)
12-25 03:33:42.214: E/AndroidRuntime(1559): at java.lang.reflect.Method.invokeNative(Native Method)
12-25 03:33:42.214: E/AndroidRuntime(1559): at java.lang.reflect.Method.invoke(Method.java:515)
12-25 03:33:42.214: E/AndroidRuntime(1559): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
12-25 03:33:42.214: E/AndroidRuntime(1559): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
12-25 03:33:42.214: E/AndroidRuntime(1559): at dalvik.system.NativeStart.main(Native Method)
12-25 03:33:42.214: E/AndroidRuntime(1559): Caused by: java.lang.ClassCastException: android.widget.TextView cannot be cast to android.widget.LinearLayout
12-25 03:33:42.214: E/AndroidRuntime(1559): at imamalsajadsayings.android.com.MainActivity.onCreate(MainActivity.java:20)
12-25 03:33:42.214: E/AndroidRuntime(1559): at android.app.Activity.performCreate(Activity.java:5231)
12-25 03:33:42.214: E/AndroidRuntime(1559): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
12-25 03:33:42.214: E/AndroidRuntime(1559): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
12-25 03:33:42.214: E/AndroidRuntime(1559): ... 11 more
12-25 03:33:43.064: D/dalvikvm(1559): DexOpt: --- BEGIN 'ads478949099.jar' (bootstrap=0) ---
12-25 03:33:46.024: D/dalvikvm(1559): DexOpt: --- END 'ads478949099.jar' (success) ---
12-25 03:33:46.024: D/dalvikvm(1559): DEX prep '/data/data/imamalsajadsayings.android.com/cache/ads478949099.jar': unzip in 54ms, rewrite 2963ms
12-25 03:33:46.844: I/Ads(1559): adRequestUrlHtml: <html><head><script src="http://media.admob.com/sdk-core-v40.js"></script><script>AFMA_getSdkConstants();AFMA_buildAdURL({"preqs":0,"session_id":"5927457787414134416","seq_num":"1","slotname":"a152b5665edfefd","u_w":384,"msid":"imamalsajadsayings.android.com","cap":"m,a","js":"afma-sdk-a-v6.4.1","bas_off":0,"net":"ed","app_name":"3.android.imamalsajadsayings.android.com","hl":"en","gnt":3,"carrier":"310260","u_audio":4,"kw":[],"u_sd":2,"simulator":1,"ms":"OPbcxzOd9lJImWjXOtp3hqpv26-cVzCC2CRXlOnJL4iR9JnqERa-t0gYOUEDfm9_ZdloVn6JYXvSi2W_T-OmyZGApgUSdoc5Ymf5xM0wqWv4Q1-L-cPGOlLqFb__qZoBPosFpAT3wG8rSE4SjadFbESExgSB07bJ9U3TVzf2AlhGPQR-7N41d3arIEUnV2UCOeer6Y6n_imlZs00ubvpKIcI5sAN2ZBIIoZhg4Qi35EBNf6nHyiKHVecGbgmnf6PDDO1xU1MfLOSdMQeqKZQWyiIsXWPGCBZ6wqyhJmCfeABwzF4p0G6y_gKB2r9xs_HzB4e8lrIQm_l1chnFG96Tg","isu":"B3EEABB8EE11C2BE770B684D95219ECB","format":"320x50_mb","oar":0,"ad_pos":{"height":0,"visible":0,"y":0,"x":0,"width":0},"u_h":592,"pt":1,"bas_on":0,"ptime":0});</script></head><body></body></html>
12-25 03:33:48.574: I/Process(1559): Sending signal. PID: 1559 SIG: 9
这是我的 MainActivity.java
package imamalsajadsayings.android.com;
import android.app.Activity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.view.View.OnClickListener;
public class MainActivity extends Activity {
private LayoutInflater inflater;
private LinearLayout someLayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
someLayout = (LinearLayout) findViewById(R.id.state2); //layout present in activity_main
inflater = (LayoutInflater)getSystemService(LAYOUT_INFLATER_SERVICE);
runNextTask();
}
public void runNextTask(){
LinearLayout mInflatedLayout = (LinearLayout) inflater.inflate(R.layout.activity_main, null);
@SuppressWarnings("unused")
final TrackerInfo newInfo = new TrackerInfo();
//set up for model selection
TextView modelTextview = (TextView)mInflatedLayout.findViewById(R.id.state2);
someLayout.addView(mInflatedLayout);
modelTextview.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
}
});
}
@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
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/relLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="right"
android:orientation="vertical"
tools:context=".MainActivity" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:orientation="vertical"
android:background="@drawable/images" >
<com.google.ads.AdView
android:id="@+id/ad"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="a152b5665edfefd"
ads:loadAdOnCreate="true"
ads:adSize="BANNER" />
<TextView
android:id="@+id/state1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="قال (عليه السلام): (من كرمت عليه نفسه هانت عليه الدنيا) "
android:paddingTop="10sp"
android:clickable = "false"
style="?android:listSeparatorTextViewStyle" />
<TextView
android:id="@+id/state2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="قال (عليه السلام): (الخير كله في صيانة الإنسان نفسه) "
android:paddingTop="10sp"
style="?android:listSeparatorTextViewStyle"
android:clickable="true"
android:onClick="runNextTask"/>
<TextView
android:id="@+id/state3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="قال (عليه السلام): (ما أحب المؤمن معافى في الدنيا، وفي نفسه وماله، ولا يصاب بشيء من المصائب)"
android:paddingTop="10sp"
android:clickable = "true"
style="?android:listSeparatorTextViewStyle"/>
<TextView
android:id="@+id/state4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" قال (عليه السلام): (ضل من ليس له حليم يرشده، وذل من ليس له سفيه يعضده..) "
android:paddingTop="10sp"
android:clickable = "true"
style="?android:listSeparatorTextViewStyle"/>
<TextView
android:id="@+id/state5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="قال (عليه السلام): (ويل لمن غلبت آحاده أعشاره) "
android:paddingTop="10sp"
android:clickable = "true"
style="?android:listSeparatorTextViewStyle"/>
<TextView
android:id="@+id/state6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="قال (عليه السلام): (اللئيم يأكل ماله الأعداء، والذي خبث لا يخرج إلا نكداً..) "
android:paddingTop="10sp"
android:clickable = "true"
style="?android:listSeparatorTextViewStyle"/>
<View
android:id="@+id/view3"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/state7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" قال (عليه السلام): (إن الجسد إذا لم يمرض يأشر ولا خير في جسد يأشر..) "
android:paddingTop="10sp"
android:clickable = "true"
style="?android:listSeparatorTextViewStyle"/>
<TextView
android:id="@+id/state8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="قال (عليه السلام): (عليكم بأداء الأمانة، فوالذي بعث محمداً بالحق نبياً لو أن قاتل أبي الحسين بن علي ائتمنني على السيف الذي قتله به لأديته إليه..)"
android:paddingTop="10sp"
android:clickable = "true"
style="?android:listSeparatorTextViewStyle"/>
<TextView
android:id="@+id/state9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="قال (عليه السلام): (أفضل الأعمال عند الله ما عمل بالسنة) "
android:paddingTop="10sp"
android:clickable = "true"
style="?android:listSeparatorTextViewStyle"/>
<TextView
android:id="@+id/state9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="قال (عليه السلام): (لقد استرقك بالود من سبقك بالشكر..) "
android:paddingTop="10sp"
android:clickable = "true"
style="?android:listSeparatorTextViewStyle"/>
<TextView
android:id="@+id/state10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="قال (عليه السلام): (لا يكون الصديق صديقاً حتى يقطع لأخيه المؤمن قطعة من دينه يرقعها بالاستغفار..)"
android:paddingTop="10sp"
android:clickable = "true"
style="?android:listSeparatorTextViewStyle"/>
<TextView
android:id="@+id/state11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="قال (عليه السلام): (ضمنت على ربي أنه لا يسال أحد من غير حاجة إلا اضطرته المسألة يوماً إلى أن يسأل من حاجة..)"
android:paddingTop="10sp"
android:clickable = "true"
style="?android:listSeparatorTextViewStyle"/>
<TextView
android:id="@+id/state12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="قال (عليه السلام): (إياك، وما تعتذر منه) "
android:paddingTop="10sp"
android:clickable = "true"
style="?android:listSeparatorTextViewStyle"/>
<TextView
android:id="@+id/state13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="قال (عليه السلام): (إن الله جل جلاله يقول: وعزتي وعظمتي وجمالي، وبهائي، وعلوي، وارتفاع مكان لا يؤثر عبد هواي على هواه إلا جعلت همه في آخرته، وغناه في قلبه، كففت عنه ضيعته، وضمنت السماوات والأرض رزقه، وأتته الدنيا وهي راغمة)"
android:paddingTop="10sp"
android:clickable = "true"
style="?android:listSeparatorTextViewStyle"/>
<TextView
android:id="@+id/state14"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="قال (عليه السلام): (رب مغرور، مفتون، يصبح لاهياً ضاحكاً، يأكل ويشرب، وهو لا يدري لعله قد سبقت له من الله سخطه، يصلى بها نار جهنم..)"
android:paddingTop="10sp"
android:clickable = "true"
style="?android:listSeparatorTextViewStyle"/>
</LinearLayout>
</ScrollView>
最佳答案
您错误地初始化了 TextView
因为您在布局中添加了 TextView
并且您尝试使用 LinearLayout
初始化它,这是错误的.
在 onCreate() 中将 LinearLayout
更改为 TextView
,如下所示:
someLayout = (TextView) findViewById(R.id.state2);
为什么要在代码中将布局膨胀两次?我不明白你为什么要这样做。但我正在提供带有一些相关代码的代码,请尝试使用我的代码。
public class MainActivity extends Activity {
private LayoutInflater inflater;
private TextView someLayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
someLayout = (TextView) findViewById(R.id.state2); //layout present in activity_main
// inflater = (LayoutInflater)getSystemService(LAYOUT_INFLATER_SERVICE);
runNextTask();
}
public void runNextTask(){
// LinearLayout mInflatedLayout = (LinearLayout) inflater.inflate(R.layout.activity_main, null);
@SuppressWarnings("unused")
final TrackerInfo newInfo = new TrackerInfo();
//set up for model selection
// TextView modelTextview = (TextView)mInflatedLayout.findViewById(R.id.state2);
//someLayout.addView(mInflatedLayout);
someLayout.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
}
});
}
仅供引用,您无法在 TextView
中添加任何布局,因为它的 View
不是 Layout
并且在您的代码中我看到您正在尝试将 Layout
添加到 View
中,这是错误的。
关于java - 在 TextView 中添加 OnClick(View v),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20770929/
我创建了一个用户可以添加测试的字段。这一切运行顺利我只希望当用户点击(添加另一个测试)然后上一个(添加另一个测试)删除并且这个显示在新字段中。 所有运行良好的唯一问题是点击(添加另一个字段)之前添加另
String[] option = {"Adlawan", "Angeles", "Arreza", "Benenoso", "Bermas", "Brebant
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 这个问题似乎不是关于 a specific programming problem, a softwar
我正在努力将 jQuery 滚动功能添加到 nav-tab (Bootstrap 3)。我希望用户能够选择他们想要的选项卡,并在选项卡内容中有一个可以平滑滚动到 anchor 的链接。这是我的代码,可
我正在尝试在用户登录后再添加 2 个 ui 选项卡。首先,我尝试做一个之后。 $('#slideshow').tabs('remove', '4'); $("#slideshow ul li:last
我有一个包含选择元素的表单,我想通过选择添加和删除其中一些元素。这是html代码(这里也有jsfiddle http://jsfiddle.net/txhajy2w/):
正在写这个: view.backgroundColor = UIColor.white.withAlphaComponent(0.9) 等同于: view.backgroundColor = UICo
好的,如果其中有任何信息,我想将这些列添加到一起。所以说我有 账户 1 2 3 . 有 4 个帐户空间,但只有 3 个帐户。我如何创建 java 脚本来添加它。 最佳答案 Live Example H
我想知道是否有一种有效的预制算法来确定一组数字的和/差是否可以等于不同的数字。示例: 5、8、10、2,使用 + 或 - 等于 9。5 - 8 = -3 + 10 = 7 + 2 = 9 如果有一个预
我似乎有一个卡住的 git repo。它卡在所有基本的添加、提交命令上,git push 返回所有内容为最新的。 从其他帖子我已经完成了 git gc 和 git fsck/ 我认为基本的调试步骤是
我的 Oracle SQL 查询如下- Q1- select hca.account_number, hca.attribute3, SUM(rcl.extended_amou
我正在阅读 http://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingG
我正在尝试添加一个“加载更多”按钮并限制下面的结果,这样投资组合页面中就不会同时加载 1000 个内容,如下所示:http://typesetdesign.com/portfolio/ 我对 PHP
我遇到这个问题,我添加了 8 个文本框,它工作正常,但是当我添加更多文本框(如 16 个文本框)时,它不会添加最后一个文本框。有人遇到过这个问题吗?提前致谢。 Live Link: JAVASCRIP
add/remove clone first row default not delete 添加/删除克隆第一行默认不删除&并获取正确的SrNo(例如:添加3行并在看到问题后删除SrNo.2)
我编码this ,但删除按钮不起作用。我在控制台中没有任何错误.. var counter = 0; var dataList = document.getElementById('materi
我有一个类似数组的对象: [1:数组[10]、2:数组[2]、3:数组[2]、4:数组[2]、5:数组[3]、6:数组[1]] 我正在尝试删除前两个元素,执行一些操作,然后将它们再次插入到同一位置。
使用的 Delphi 版本:2007 你好, 我有一个 Tecord 数组 TInfo = Record Name : String; Price : Integer; end; var Info
我使用了基本的 gridster 代码,然后我声明了通过按钮添加和删除小部件的函数它工作正常但是当我将调整大小功能添加到上面的代码中时,它都不起作用(我的意思是调整大小,添加和删除小部件) 我的js代
title 323 323 323 title 323 323 323 title 323 323 323 JS $(document).keydown(function(e){
我是一名优秀的程序员,十分优秀!