我已搜索了不少地方,但我还没有找到任何有效的解决方案,我真的需要帮助!我正在创建一个需要将经度和纬度字符串从一个活动传递到另一个活动的应用程序.我怎样才能做到这一点???看看我的代码:LocationActivity.java需要将字符串传递给另一个活动,另一个我没有粘贴到这里.需要传递的字符串名为:"latLongString"
LocationActivity.java:
import android.R.string;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
public class LocationActivity extends Activity {
private String Location;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LocationManager locManager;
locManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
locManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,1000L,500.0f, locationListener);
Location location = locManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
updateWithNewLocation(location);
if(location != null)
{
double latitude = location.getLatitude();
double longitude = location.getLongitude();
}
}
private void updateWithNewLocation(Location location) {
TextView myLocationText = (TextView)findViewById(R.id.LocationWord);
String latLongString = "";
if (location != …Run Code Online (Sandbox Code Playgroud) 我需要通过在Windows Phone的两页8.我一直在寻找周围之间的一个简单的字符串,试图找到这样做的最好办法 - 但我想的那些被证明行不通,因为他们应该 - 所以我问你:在Windows Phone 8中两个页面之间传递简单字符串的最佳方法是什么.这是我用于导航到另一个页面的方法:
NavigationService.Navigate(new Uri("/newpage.xaml", Urikind.Relative));
Run Code Online (Sandbox Code Playgroud) 我在我的应用程序中需要输入提示,我已经尝试过了
// Create a new item
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"New item" message:@"Enter a name for the item" delegate:nil cancelButtonTitle:@"Cancel" otherButtonTitles:@"Add", nil];
alert.alertViewStyle = UIAlertViewStylePlainTextInput;
[alert show];
Run Code Online (Sandbox Code Playgroud)
然后像这样处理它:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
// The user created a new item, add it
if (buttonIndex == 1) {
// Get the input text
NSString *newItem = [[alertView textFieldAtIndex:0] text];
}
}
Run Code Online (Sandbox Code Playgroud)
但它看起来不像clickedButtonAtIndex被调用,为什么?
亲切的问候,Erik
我试图简单地将一个字符串列表保存到Windows Phone 8上的独立存储.我只是创建了一个列表并以这种方式保存:
IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings;
List<String> projectList = new List<String>();
projectList.add("yo");
settings.add("yo", projectList");
settings.Save();
Run Code Online (Sandbox Code Playgroud)
如何在应用程序再次启动时从IsolatedStorage读取此数据并将其放入同一列表中?我正在寻找一种简单的方法 - 我没有在网上找到,我没有设法实现我在网上找到的任何解决方案,因为他们使用不同的方法.
请帮忙,非常感谢!
在我的C#Windows Phone 8应用程序中,我有一个AppBar.我在这个AppBar上有两个图标,一个新图标和一个编辑图标.我想在按下时将编辑图标更改为后退图标,然后再次按下时再返回编辑图标.我试过这段代码,但是我得到一个nullReferenceException:
public static Uri addIcon = new Uri("/Assets/AppBar/new.png", UriKind.Relative);
public static Uri backIcon = new Uri("/Assets/AppBar/back.png", UriKind.Relative);
//Edit the projects
if (editMode.Equals(false))
{
//EditMode is off, enable edit mode and modify the editprojectMenuButton
editMode = true;
editprojectMenuButton.IconUri = backIcon;
editprojectMenuButton.Text = "finish";
} else
{
//EditMode is on, disable edit mode and modify the editprojectMenubutton
editMode = false;
editprojectMenuButton.IconUri = addIcon;
editprojectMenuButton.Text = "edit";
}
Run Code Online (Sandbox Code Playgroud)
Xaml代码:
<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
<shell:ApplicationBarIconButton x:Name="editprojectMenuButton" IconUri="/Assets/AppBar/edit.png" Text="Edit" Click="editprojectMenuButton_Click"/>
<shell:ApplicationBarIconButton x:Name="addprojectMenuButton" IconUri="/Assets/AppBar/new.png" …Run Code Online (Sandbox Code Playgroud) 我正在构建一个 android 应用程序,我需要在其中创建一个简单的字符串项目列表,然后我将为列表中的每个项目添加一个特定的控件。
这是我要创建的列表:
List<String> projects = new List<String>(); // How?
Run Code Online (Sandbox Code Playgroud)
我正在尝试的代码:
String projects = new string[] { "hey","yo","app","xamarin","c","xaml" };
Run Code Online (Sandbox Code Playgroud)
我需要计算项目,像这样:
int amount = projects.Count(); // Can I do this?
Run Code Online (Sandbox Code Playgroud)
然后为列表中的每个项目添加控件
// Add the tiles, one by one
for (int i = 0; i < amount; i++)
{
// Inflate the tile
var tile = LayoutInflater.Inflate (Resource.Layout.Tile, null);
// Set its attributes
tile.FindViewById<TextView> (Resource.Id.projectName).Text = currentProject;
// Add the tile
projectScrollView.AddView (tile);
}
Run Code Online (Sandbox Code Playgroud)
“currentProject”字符串是从 SharedPreferences 中检索到的,只是还没有那么远
我有一个控件列表,放入stackpanel.这些控件是Hubtiles,在用户创建后以编程方式添加 - 本质上是一个列表.我需要制作添加它们的StackPanel,可滚动 - 对此最好的方法是什么?我应该将堆栈面板放在ScrollView中,然后使用Hubtile的实际高度增加StackPanels高度 - 使其可滚动,但不是这样,用户可以在没有任何东西的情况下滚动无限.因此,只要StackPanel内的控件数量达到3,它就会自动增加它的高度,如下所示:
只要StackPanel内的控件数量达到3或更高:
StackPanel.Height = StackPanel.Height + Hubtile.ActualHeight;
Run Code Online (Sandbox Code Playgroud)
非常感谢!
我的应用程序中有一些自定义控件。这些自定义控件之一包含渐变背景,我希望用户能够动态地在线性和径向渐变样式之间切换。我如何在代码中执行此操作?我的自定义控件 XAML:
<UserControl x:Class="App.tile"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}" Height="191.94" Width="406.91">
<Grid x:Name="LayoutRoot">
<Grid.Background>
<RadialGradientBrush>
<GradientStop Color="#FF092949" Offset="0"/>
<GradientStop Color="#FF06192C" Offset="1"/>
</RadialGradientBrush>
</Grid.Background>
<TextBlock HorizontalAlignment="Left" Margin="10,134,0,0" TextWrapping="Wrap" x:Name="tileTitle" Text="Project" VerticalAlignment="Top" FontSize="36"/>
</Grid>
</UserControl>
Run Code Online (Sandbox Code Playgroud)
我将更改其外观的代码:
private void linearRadioButton_Checked(object sender, RoutedEventArgs e)
{
// The linearRadioButton was checked, update the exampleTile
}
Run Code Online (Sandbox Code Playgroud)
多谢!
更新:
现在尝试过这个:
<phone:PhoneApplicationPage.Resources>
<LinearGradientBrush x:Key="linearBrush" StartPoint="0,0.5" EndPoint="1,0.5">
<GradientStop Color="Yellow" Offset="0.0" />
<GradientStop Color="Red" Offset="0.25" />
<GradientStop Color="Blue" Offset="0.75" />
<GradientStop Color="LimeGreen" Offset="1.0" /> …Run Code Online (Sandbox Code Playgroud) 所以我正在创建这个应用程序,我已经创建了自己的用户控件,并且每个控件都有一些内容将使用来自Web的信息进行更新,但我不知道如何添加属性.就像那个特定控件的名字一样.比如控件中存储的高度设置在哪里?在代码中?像这样
mycontrol:
String nameofthiscontrol = "control";
Run Code Online (Sandbox Code Playgroud)
和主要代码:
mycontrol mycontrol = new mycontrol();
mycontrol.nameofthiscontrol = "control1";
Run Code Online (Sandbox Code Playgroud)
它是如何工作的?我真的需要一些指导,请帮忙!提前致谢!
c# ×6
android ×2
list ×2
brush ×1
controls ×1
dynamic ×1
for-loop ×1
gradient ×1
height ×1
icons ×1
ios ×1
location ×1
objective-c ×1
properties ×1
stackpanel ×1
tile ×1
uialertview ×1