public class SettingsActivity extends SherlockPreferenceActivity implements OnSharedPreferenceChangeListener, OnPreferenceChangeListener {
@SuppressWarnings("deprecation")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.settings);
getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
ListPreference theme = (ListPreference) getPreferenceScreen().findPreference("theme");
theme.setSummary(theme.getValue().toString());
theme.setOnPreferenceChangeListener(this);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
getSupportActionBar().setTitle(R.string.menu_preferences);
}
@SuppressWarnings("deprecation")
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
String key) {
if (key.equals("theme")) {
SharedPreferences.Editor editor = sharedPreferences.edit();
ListPreference theme = (ListPreference) getPreferenceScreen().findPreference("theme");
theme.setSummary(theme.getEntry());
editor.putString("theme", theme.getEntry().toString());
editor.commit();
}
}
public boolean onPreferenceChange(Preference preference, Object newValue) {
ListPreference theme = (ListPreference) preference;
theme.setSummary(theme.getEntry());
return true;
}
}
Run Code Online (Sandbox Code Playgroud)
我明白了:
07-03 09:46:22.563: E/AndroidRuntime(421): java.lang.StackOverflowError
07-03 09:46:22.563: …Run Code Online (Sandbox Code Playgroud) 这是我的方法:
private void ConvertValues()
{
txtResult.Text = angles[cmbUnits1.SelectedIndex];
double value1 = Convert.ToDouble(txtValue1.Text);
double value2 = Convert.ToDouble(txtValue2.Text);
int unit1 = cmbUnits1.SelectedIndex;
}
Run Code Online (Sandbox Code Playgroud)
我想要的方法是获取所选的ComboBox并测试值.但我想知道是否有替代方案:
if( angles[cmbUnits1.SelectedIndex].Equals("Degrees") &&
angles[cmbUnits2.SelectedIndex].Equals("Radians")) {
...
}
Run Code Online (Sandbox Code Playgroud)
顺便说一句,我正在制作一种单位转换器,所以我将有除角度以外的部分.所以我想要一些我可以实现的枚举,接口,抽象类或类.也许是一个名为Unit的班级?所以我可以创建像Unit degrees = new Unit(Units.Angle)Units这样的新对象作为枚举.还是只是Unit sqrMillimeters = new Unit("Area");?
如何使用Win32图标,如打开图标,新文件图标和保存图标.我必须将它们下载为图像吗?或者是dll中的图像?也许System.Windows.Shell?
如何解决生成的异常?
public static string[] getKeywords(string filename)
{
var xmlFile = new XElement(filename);
string[] keywords = xmlFile.Elements("Keyword")
.Attributes("name")
.Select(n => n.Value).ToArray();
return keywords;
}
Run Code Online (Sandbox Code Playgroud)
这会生成此异常:
System.Xml.XmlException未处理Message ='/'字符,十六进制值0x2F,不能包含在名称中.来源=的System.Xml
我在我的应用程序中使用SQL Server Compact Edition(本地数据库).但是当我使用实体框架时,我一直遇到一个非常烦人的UpdateException.我的数据库只有两个小表,外键关系将它们连接在一起.所以我问是否有数据库的替代品?或者这是唯一的选择吗?
更新:
这是EDMX地图.
以下是System.Windows.Markup.XamlParseException was unhandled
Message=Cannot create instance of 'MainWindow' defined in assembly 'AssignmentOrganizer, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Exception has been thrown by the target of an invocation. Error in markup file 'AssignmentOrganizer;component/MainWindow.xaml' Line 1 Position 9.
Source=PresentationFramework
LineNumber=1
LinePosition=9
StackTrace:
at System.Windows.Markup.XamlParseException.ThrowException(String message, Exception innerException, Int32 lineNumber, Int32 linePosition, Uri baseUri, XamlObjectIds currentXamlObjectIds, XamlObjectIds contextXamlObjectIds, Type objectType)
at System.Windows.Markup.XamlParseException.ThrowException(ParserContext parserContext, Int32 lineNumber, Int32 linePosition, String message, Exception innerException)
at System.Windows.Markup.BamlRecordReader.ThrowExceptionWithLine(String message, Exception innerException)
at …
我已经安装了Visual Studio 2010 RC.我想安装Visual C#2008,因为XNA Game Studio需要安装它.我可以并排运行它们吗?
我是C的新手,我正在阅读指针如何"指向"另一个变量的地址.所以我尝试了间接调用和直接调用,并收到了相同的结果(正如任何C/C++开发人员所预测的那样).这就是我做的:
int cost;
int *cost_ptr;
int main()
{
cost_ptr = &cost; //assign pointer to cost
cost = 100; //intialize cost with a value
printf("\nDirect Access: %d", cost);
cost = 0; //reset the value
*cost_ptr = 100;
printf("\nIndirect Access: %d", *cost_ptr);
//some code here
return 0; //1
}
Run Code Online (Sandbox Code Playgroud)
所以我想知道使用指针的间接调用是否比直接调用有任何优势,反之亦然?一些优点/缺点可能包括速度,执行操作所消耗的内存量(很可能相同,但我只想把它放在那里),安全性(如悬挂指针),良好的编程习惯等
.1有趣的是,我是使用GNU C编译器(gcc),它仍然编译没有return语句,一切都按预期.也许是因为如果你忘了,C++编译器会自动插入return语句.
每当我尝试使用我的内容提供程序插入URI时,我都会收到此错误.这是方法:
private void sample() {
ContentValues values;
values = new ContentValues();
values.put(Formulas.TITLE, "Formula1");
values.put(Formulas.FORMULA, "someformula");
getContentResolver().insert(getIntent().getData(), values);
values = new ContentValues();
values.put(Formulas.TITLE, "Formula2");
values.put(Formulas.FORMULA, "someformula");
getContentResolver().insert(getIntent().getData(), values);
values = new ContentValues();
values.put(Formulas.TITLE, "Formula3");
values.put(Formulas.FORMULA, "someformula");
getContentResolver().insert(getIntent().getData(), values);
}
Run Code Online (Sandbox Code Playgroud)
以前我在这里设置Intent数据:
Intent intent = getIntent();
if (intent.getData() == null)
intent.setData(Formulas.CONTENT_URI);
Run Code Online (Sandbox Code Playgroud)
这是我的内容URI和权限:
public static final String AUTHORITY = "com.mohit.provider.FormulaProvider";
public static final Uri CONTENT_URI = Uri.parse("content:\\" + AUTHORITY + "\formulas");
Run Code Online (Sandbox Code Playgroud)
这是提供者标签:
<provider android:name="com.mohit.provider.FormulaProvider"
android:authorities="com.mohit.provider.FormulaProvider" />
Run Code Online (Sandbox Code Playgroud)
最后是Logcat日志:
08-22 14:42:07.362: ERROR/AndroidRuntime(338): FATAL EXCEPTION: main
08-22 …Run Code Online (Sandbox Code Playgroud) 我想使用我的程序:
./program -I /usr/include/ /usr/bin/ /usr/local/include/ ...
Run Code Online (Sandbox Code Playgroud)
交换机可以像var args列表一样继续运行.我怎么能在C99那样做?最好得到一个类似char **args_list或char *args_list[]包含所有喜欢的东西/usr/include和/usr/bin/.
c# ×5
android ×2
c ×2
c99 ×1
combobox ×1
commit ×1
comparison ×1
database ×1
email ×1
indirection ×1
invocation ×1
java ×1
pointers ×1
uri ×1
winapi ×1
winforms ×1
wpf ×1
xmlexception ×1