我正在写一个Android应用程序,我想改变我的应用程序的主题.
我已经设法通过使用主题来改变应用程序的背景颜色,但我正在努力改变默认的文本外观.
这是我的styles.xml资源文件.
<resources>
<style name="QTheme" parent="android:Theme.Light">
<item name="android:windowBackground">@color/q_green</item>
<item name="android:colorBackground">@color/q_green</item>
<item name="android:textAppearance">@style/QText</item>
</style>
<color name="q_green">#008000</color>
<color name="white">#FFFFFF</color>
<style name="QText" parent="@android:style/TextAppearance.Medium">
<item name="android:textSize">20sp</item>
<item name="android:textColor">@color/white</item>
<item name="android:textStyle">bold</item>
<item name="android:textFont">Verdana</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
并且只是为了检查,这是我的一个TextViews的例子我想在我的布局文件中使用上面的样式.
<TextView
android:id="@+id/txtDevice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/device"
/>
Run Code Online (Sandbox Code Playgroud)
任何人都可以看到我错在哪里?
我有一个Android应用程序,其屏幕包含一个ListView,我用它来显示设备列表.这些设备保存在一个阵列中.
我正在尝试使用ArrayAdapter在列表中的屏幕上显示数组中的内容.
它在我第一次加载SetupActivity类时有效,但是,可以在addDevice()方法中添加新设备,这意味着更新了保存设备的阵列.
我正在使用notifyDataSetChanged(),它应该更新列表,但它似乎不起作用.
public class SetupActivity extends Activity
{
private ArrayList<Device> deviceList;
private ArrayAdapter<Device> arrayAdapter;
private ListView listView;
private DevicesAdapter devicesAdapter;
private Context context;
public void onCreate(Bundle savedInstanceState) //Method run when the activity is created
{
super.onCreate(savedInstanceState);
setContentView(R.layout.setup); //Set the layout
context = getApplicationContext(); //Get the screen
listView = (ListView)findViewById(R.id.listView);
deviceList = new ArrayList<Device>();
deviceList = populateDeviceList(); //Get all the devices into the list
arrayAdapter = new ArrayAdapter<Device>(this, android.R.layout.simple_list_item_1, deviceList);
listView.setAdapter(arrayAdapter);
}
protected …Run Code Online (Sandbox Code Playgroud) java android android-arrayadapter android-listview android-activity
我的android程序有以下方法,用Java编写.
该方法接受一个十六进制字符串,并返回以ascii编写的相同文本的字符串.
public static String hexToString(String hex)
{
StringBuilder sb = new StringBuilder();
for (int count = 0; count < hex.length() - 1; count += 2)
{
String output = hex.substring(count, (count + 2)); //grab the hex in pairs
int decimal = Integer.parseInt(output, 16); //convert hex to decimal
sb.append((char)decimal); //convert the decimal to character
}
return sb.toString();
}
Run Code Online (Sandbox Code Playgroud)
该方法工作正常,但我的程序非常关键,这种方法可能被称为成千上万次.在分析程序的慢速位时,由于以下原因,此方法占用了太多时间:
Integer.parseInt(output, 16);
Run Code Online (Sandbox Code Playgroud)
和
hex.substring(count, (count + 2));
Run Code Online (Sandbox Code Playgroud)
以最慢的顺序排在第一位.
有谁知道更快的方法来实现同样的事情?
我有一个页面(不幸的是位于登录系统后面),它基本上在文章列表的左侧有一个导航栏,当您单击一篇文章时,它会从存储在服务器上的 .inc 文件加载内容,使用提供的文件路径。
这在 Google Chrome 上运行良好。
然而,在 Firefox 上,当页面加载时,我收到这个奇怪的 javascript 错误:
“文档元素后的垃圾” - 当我单击该错误时,它会将我带到正在加载的第一篇文章的内容的第 2 行。
让我向您展示一些代码。
这是页面加载完成后运行的最后一个 JS 函数,其目的是加载初始文章。
function initialise_family_center_page()
{
if (current_element_id == "" || current_element_id == "family_center_general_info") //If this is the first article to be loaded
{
//Get the file path of the inc file to load
var content_directory = file path....;
jQuery.get(content_directory, function(data)
{
$('#family_center_main_content').html(data); //Load the content
});
}
}
Run Code Online (Sandbox Code Playgroud)
正在加载的.inc文件中的内容如下:
<p>Some text</p>
<p>Some text</p>
Run Code Online (Sandbox Code Playgroud)
此时值得一提的是,在 Chrome 和 Firefox 中,内容会加载。然而在firefox中,由于JS错误,你不能再使用页面的其余部分,因为JS已经停止工作。
我通过谷歌搜索问题发现的有趣的一点是,如果我将文件的内容更改为:
<html>
<p>Some …Run Code Online (Sandbox Code Playgroud) 我有一个Android应用程序(用java编写),它有两个按钮(连接和请求数据).
单击每个按钮时,将执行任务并显示进度对话框以显示任务已完成的程度.
为了显示进度对话框,单击每个按钮时,任务将在一个线程上运行.
该连接按钮只是有一个任务-线程上运行.但是,请求数据按钮执行两个任务 - 线程上的第一个任务类似于连接按钮,还有第二个任务,refreshInfo()必须在线程上的第一个任务之后运行,progThread完成.
private Button connectButton;
private Button requestDataButton;
private ProgressDialog connectionDialog;
private ProgressDialog requestDataDialog;
private ProgressThread progThread;
private int currentDialog;
public void connectClick(View view) //When the connect button is clicked
{
performAction(1); //Run the thread to perform the action
}
public void requestDownloadClick(View view) //When the request data button is clicked
{
performAction(2); //Run the thread to perform the action
refreshInfo(); //Do …Run Code Online (Sandbox Code Playgroud) 我正在寻找一种方法,能够在运行时检索我正在运行的计算机的IP子网掩码,在Delphi中.
代码中有没有办法检索子网掩码并存储它以便我可以在其他操作中使用它?
谢谢
我有一个带有表单的php页面,它有一个按钮.单击该按钮时,将运行jquery函数,该函数执行一些验证测试,然后使用ajax提交表单.在由ajax运行的php脚本中,设置了一个cookie.在设置cookie之后,我立即尝试获取cookie值,我从脚本回显并在ajax请求的成功函数中吐出.cookie值尚未设置.
代码如下.
mainpage.php
<script type="text/javascript">
$( document ).ready(function()
{
$('#submit_compare_stage1').click(function()
{
//Validation stuff
if (passed_validation)
{
var form_data = $('#compare_form').serialize(); //Collect query details into a form
$.ajax({
type: "POST",
url: "scripts/process_compare.php",
data: form_data,
success: function(data)
{
alert(data);
},
error: function(jqXHR, textStatus, errorThrown)
{
//Error stuff
}
});
}
return false;
});
});
</script>
<form name="compare_form" id="compare_form" action="">
....
<button id='submit_compare_stage1' name='submit_compare_stage1'>Next</button>
</form>
Run Code Online (Sandbox Code Playgroud)
process_compare.php
<?php
//MySQL Stuff
makeCookie('cs', '2');
echo 'hi' . getCookie('cs', false);
echo "success";
function makeCookie($name, $contents, $length = …Run Code Online (Sandbox Code Playgroud) 我有一个看似非常简单的方法,用java编写的android应用程序:
编辑1:私有字符串newResponse;
public SOME METHOD CALLED FIRST
{
newResponse = "";
}
Run Code Online (Sandbox Code Playgroud)
编辑结束1
public synchronized void reportMessage(String message)
{
try
{
newResponse = newResponse + message;
confirmQE(); //Look for qe in the message
}
catch (Exception e)
{
response = e.getCause().toString();
}
}
Run Code Online (Sandbox Code Playgroud)
当我在调试器模式下运行应用程序时,它'挂起'在该行上:
newResponse = newResponse + message;
Run Code Online (Sandbox Code Playgroud)
它在调试窗口中说:
线程[<9>线程-10](暂停(异常NullPointerException))
这种情况仅在某些时候发生.有时它会很好地运行.
它永远不会进入catch子句,当您单击继续时,应用程序崩溃.线路上没有断点,所以我甚至不知道为什么它会暂停.
newResponse的类型为String,定义为全局变量.
有人可以帮忙吗?