我有TextView
以下分配代码:
Answer1TextView = (TextView) findViewById(R.id.editText1);
Answer1TextView.setOnClickListener(answer1TextViewListener);
Run Code Online (Sandbox Code Playgroud)
这是我的onClickListener:
private OnClickListener answer1TextViewListener = new OnClickListener()
{
public void onClick(View v)
{
if(Answer1Win){
Toast.makeText(QuizScreen.this,"Correct ",2).show();
} else
{
Toast.makeText(QuizScreen.this,"Incorrect, Pick Another Answer",2).show();
}
}
};
Run Code Online (Sandbox Code Playgroud)
我的问题是双击后只显示Toast.我找不到设置驱动器这种行为,单击后不能显示的设置错误.
在我使用Visual Studio 11 Express Beta编写的Windows 8应用程序中,我无法使用ArrayList.这是我的代码:
using System.Collections;
ArrayList al = new ArrayList();
Run Code Online (Sandbox Code Playgroud)
编译错误:
找不到类型或命名空间名称'ArrayList'(您是否缺少using指令或程序集引用?)
这是新的东西吗?我喜欢ArrayLists :)
我试图找回之间的所有文字<td>
和</td>
,但我只得到我的集合中的第一场比赛.我需要一个*
什么东西吗?这是我的代码.
string input = @"<tr class=""row0""><td>09/08/2013</td><td><a href=""/teams/nfl/new-england-patriots/results"">New England Patriots</a></td><td><a href=""/boxscore/2013090803"">L, 23-21</a></td><td align=""center"">0-1-0</td><td align=""right"">65,519</td></tr>";
string pattern = @"(?<=<td>)[^>]*(?=</td>)";
MatchCollection matches = Regex.Matches(input, pattern);
foreach (Match match in matches)
{
try
{
listBoxControl1.Items.Add(matches.ToString());
}
catch { }
}
Run Code Online (Sandbox Code Playgroud) 我想剥离html标签,只返回标签之间的文本.这是我目前正在使用的.
string regularExpressionPattern1 = @"<td(.*?)<\/td>";
Regex regex = new Regex(regularExpressionPattern1, RegexOptions.Singleline);
MatchCollection collection = regex.Matches(value.ToString());
Run Code Online (Sandbox Code Playgroud)
我现在得到了<td>13</td>
,我只想要13
.
谢谢,
如何更改添加到项目的项目的文本颜色ListView
.我需要根据某些条件在代码中以编程方式更改颜色,并将不同的行更改为不同的文本颜色(例如,行0 =红色,行1 =白色,行3 =蓝色等).在xml布局中设置文本颜色将不符合我的要求.这是我的代码:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.listview);
setListAdapter(new ArrayAdapter<String>(ListViewEx.this,
R.layout.list_item_1, Global.availableDecks));
//something like this
//listview.getPosition(0).setTextColor(red);
//listview.getPosition(1).setTextColor(white);
//listview.getPosition(2).setTextColor(blue);
Run Code Online (Sandbox Code Playgroud)
和我的xml:
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/label"
android:layout_width="match_parent"
android:layout_height="35dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="30px"
android:layout_marginLeft="5px"
android:singleLine="true"
/>
Run Code Online (Sandbox Code Playgroud) 我用浏览器访问网站没有问题,但是当我以编程方式尝试访问网站进行抓取时,我收到以下错误.
The remote server returned an error: (500) Internal Server Error.
Run Code Online (Sandbox Code Playgroud)
这是我正在使用的代码.
using System.Net;
string strURL1 = "http://www.covers.com/index.aspx";
WebRequest req = WebRequest.Create(strURL1);
// Get the stream from the returned web response
StreamReader stream = new StreamReader(req.GetResponse().GetResponseStream());
System.Text.StringBuilder sb = new System.Text.StringBuilder();
string strLine;
// Read the stream a line at a time and place each one
while ((strLine = stream.ReadLine()) != null)
{
if (strLine.Length > 0)
sb.Append(strLine + Environment.NewLine);
}
stream.Close();
Run Code Online (Sandbox Code Playgroud)
这个让我难过.TIA
我在尝试编译和运行VS 2015 UWP应用程序时运行Mobile Emulator时出现以下错误.使用本地计算机或模拟器时,应用程序运行正常.
System.TypeInitializationException was unhandled by user code
HResult=-2146233036
Message=The type initializer for 'SQLitePCL.raw' threw an exception.
Source=SQLitePCL.raw
TypeName=SQLitePCL.raw
StackTrace:
at SQLitePCL.raw.sqlite3_open_v2(String filename, sqlite3& db, Int32 flags, String vfs)
at SQLite.SQLiteConnection..ctor(String databasePath, SQLiteOpenFlags openFlags, Boolean storeDateTimeAsTicks)
at SQLite.SQLiteConnection..ctor(String databasePath, Boolean storeDateTimeAsTicks)
at App3.MainPage.LoadSQLData()
at App3.MainPage..ctor()
at App3.App3_XamlTypeInfo.XamlTypeInfoProvider.Activate_0_MainPage()
at App3.App3_XamlTypeInfo.XamlUserType.ActivateInstance()
InnerException:
HResult=-2146233052
Message=Unable to load DLL 'sqlite3': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
Source=SQLitePCL.raw
TypeName=""
StackTrace:
at SQLitePCL.SQLite3Provider.NativeMethods.sqlite3_win32_set_directory(UInt32 directoryType, String directoryPath)
at SQLitePCL.SQLite3Provider..ctor()
at …
Run Code Online (Sandbox Code Playgroud) 我有一个带有ListBox的C#Winform.我试图删除除最后5项之外的所有项目.ListBox排序设置为Ascending.
ListBox中的项目如下所示:
2016-3-1
2016-3-2
2016-3-3
2016-3-4
...
2016-03-28
Run Code Online (Sandbox Code Playgroud)
这是我删除开头项目的代码.
for (int i = 0; i < HomeTeamListBox.Items.Count - 5; i++)
{
try
{
HomeTeamListBox.Items.RemoveAt(i);
}
catch { }
}
Run Code Online (Sandbox Code Playgroud)
我也试过了 HomeTeamListBox.Items.RemoveAt(HomeTeamListBox.Items[i]);
如何从列表中获取特定元素?
Double[] weightArray = {240.0, 220d, 230.0, 240.0, 250.0,220.0, 215.0, 220.0,215d,223d};
Double[] pulseArray= {72.0,74.0,75.0,76.0,72.0,78.0,62.0,78.0,76.0,73.0,73.0,79.0};
Double[] sysArray={120.0,120.0,120.0,120.0,120.0,120.0,120.0,120.0,120.0,120.0};
Double[] diaArray={80.0,80.0,80.0,80.0,80.0,80.0,80.0,80.0,80.0,80.0};
List<double[]> values = new ArrayList<double[]>();
for(int i=0; i<weightArray.length; i++){
values.add(new double[] {weightArray[0], weightArray[1], weightArray[2], weightArray[3], weightArray[4], weightArray[5], weightArray[6], weightArray[7],weightArray[8], weightArray[9] });
values.add(new double[] {pulseArray[0],pulseArray[1],pulseArray[2],pulseArray[3],pulseArray[4],
pulseArray[5],pulseArray[6],pulseArray[7],pulseArray[8],pulseArray[9] });
values.add(new double[] {sysArray[0],sysArray[1],sysArray[2],sysArray[3],sysArray[4],
sysArray[5],sysArray[6],sysArray[7],sysArray[8],sysArray[9] });
values.add(new double[] {diaArray[0],diaArray[1],diaArray[2],diaArray[3],diaArray[4],
diaArray[5],diaArray[6],diaArray[7],diaArray[8],diaArray[9] });
}
// Does not work
//Object element =values.get(3,2);
//String s= element.toString();
//Toast.makeText(context, s.toString() , Toast.LENGTH_SHORT).show();
Run Code Online (Sandbox Code Playgroud)
例如,我想得到值元素3,2,(diaArrray [1])