我是Android开发的新手,在改变活动时遇到了一些问题.我试图从一个方法中改变活动,但我收到错误,cannot resolve method startActivity并在参数结束时出错Cannot resolve constructor 'Intent (...)'.我在这里发现了一个同样问题的问题,并试图将他们的回复实施到我的程序中但没有快乐.
这是代码:
public void open301(View view) {
startActivity(new Intent(CustomAdapter.this, ThreeZeroOne.class));
}
Run Code Online (Sandbox Code Playgroud)
在查看上面链接的问题的回复之前,代码看起来像这样,具有相同的错误:
public void open301(View view) {
Intent openThree = new Intent(this,ThreeZeroOne.class);
startActivity(openThree);
}
Run Code Online (Sandbox Code Playgroud)
完整代码:
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import android.content.Intent;
public class CustomAdapter extends BaseAdapter {
String[] result;
Context context;
int[] imageId;
private static LayoutInflater inflater = null;
public CustomAdapter(selectGame …Run Code Online (Sandbox Code Playgroud) 我一直在尝试从2.0更新android studio到2.1并且已经没有想法了.我得到了一个
java.lang.OutOfMemoryError: Java heap space
Run Code Online (Sandbox Code Playgroud)
错误.我已经尝试过寻找解决方案并尝试过这样的解决方案而没有任何乐趣:
这是我收到的完整错误:
Temp. directory: C:\Users\Aaron\AppData\Local\Temp\
java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:3236)
at java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:118)
at java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.java:93)
at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:153)
at com.intellij.updater.Utils.copyStream(Utils.java:165)
at ie.wombat.jbdiff.JBPatch.bspatch(JBPatch.java:83)
at com.intellij.updater.BaseUpdateAction.applyDiff(BaseUpdateAction.java:112)
at com.intellij.updater.UpdateAction.doApply(UpdateAction.java:44)
at com.intellij.updater.PatchAction.apply(PatchAction.java:184)
at com.intellij.updater.Patch$3.forEach(Patch.java:308)
at com.intellij.updater.Patch.forEach(Patch.java:360)
at com.intellij.updater.Patch.apply(Patch.java:303)
at com.intellij.updater.PatchFileCreator.apply(PatchFileCreator.java:84)
at com.intellij.updater.PatchFileCreator.apply(PatchFileCreator.java:75)
at com.intellij.updater.Runner.doInstall(Runner.java:280)
at com.intellij.updater.Runner.access$000(Runner.java:17)
at com.intellij.updater.Runner$1.execute(Runner.java:246)
at com.intellij.updater.SwingUpdaterUI$5.run(SwingUpdaterUI.java:191)
at java.lang.Thread.run(Thread.java:745)
Run Code Online (Sandbox Code Playgroud)
我已通过转到"帮助">"编辑自定义VM选项"在正确的目录中创建了.vmoptions文件.创建的文件是studio64.exe.vmoptions在我编辑一行后对该文件的内容感兴趣的情况下命名的:
# custom Android Studio VM options
#
# *DO NOT* modify this file directly. If there is a value that you would …Run Code Online (Sandbox Code Playgroud) 我正在尝试搜索他们居住的城镇中存储在文本文件中的客户帐户.有三个客户帐户都有不同的城镇.我认为该程序找到了正确的客户,因为它确实返回数据写入屏幕但不是全部.这些图像更好地解释了它.试图嵌入他们,但没有积分
文本文件内容:

当搜索住在利物浦的顾客时(尽管图像没有显示,但光标开始在DOB下面闪烁5行)

寻找贝尔法斯特客户.请注意,它会选择coreect DOB,但错误的客户编号和Surname.(我把评论中的链接放在一起不会让我发布超过2个链接)
下面是方法的代码::
static void FindTown(CustomerStruct[] CustomerDeats)
{
string City;
bool CityMatch = false;
Console.Clear();
begin:
try
{
Console.WriteLine("Please enter the customers Town ");
City = Console.ReadLine();
}
catch
{
Console.WriteLine("Failed. Please try again.");
goto begin;
}
var pathToTown = @"..\..\..\Files\Customer.txt";
using (StreamReader sr = new StreamReader(pathToTown))
while (!CityMatch)
{
{
RecCount = 0;
CustomerDeats[RecCount].Town = sr.ReadLine();
if (City == CustomerDeats[RecCount].Town)
{
Console.WriteLine("\n\n");
CityMatch = true;
CustomerDeats[RecCount].CustomerNo = sr.ReadLine();
Console.WriteLine(CustomerDeats[RecCount].CustomerNo);
CustomerDeats[RecCount].Surname = sr.ReadLine();
Console.WriteLine(CustomerDeats[RecCount].Surname);
CustomerDeats[RecCount].Forename = sr.ReadLine(); …Run Code Online (Sandbox Code Playgroud) 我正在尝试实施 adMob,但我的应用程序没有启动并提供以下错误:
java.lang.RuntimeException: Unable to get provider com.google.android.gms.ads.MobileAdsInitProvider: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.ads.MobileAdsInitProvider" on path: DexPathList[[zip file "/data/app/com.aaron.derrystudios.wordresolver-mOF2EngPcA5nT8dd27zx5g==/base.apk"],nativeLibraryDirectories=[/data/app/com.aaron.derrystudios.wordresolver-mOF2EngPcA5nT8dd27zx5g==/lib/arm64, /system/lib64]]
at android.app.ActivityThread.installProvider(ActivityThread.java:7369)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:6909)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6826)
at android.app.ActivityThread.access$1400(ActivityThread.java:267)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1981)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:7762)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1047)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.ads.MobileAdsInitProvider" on path: DexPathList[[zip file "/data/app/com.aaron.derrystudios.wordresolver-mOF2EngPcA5nT8dd27zx5g==/base.apk"],nativeLibraryDirectories=[/data/app/com.aaron.derrystudios.wordresolver-mOF2EngPcA5nT8dd27zx5g==/lib/arm64, /system/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:196)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.AppComponentFactory.instantiateProvider(AppComponentFactory.java:147)
at android.app.ActivityThread.installProvider(ActivityThread.java:7353)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:6909)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6826)
at android.app.ActivityThread.access$1400(ActivityThread.java:267)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1981)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:7762)
at …Run Code Online (Sandbox Code Playgroud) 我有一个列表,我正在读取数据.我检查了如何输出列表但是对其他人有用的东西对我不起作用.我注意到我看到的所有例子都没有像我一样在列表中使用过类,我找不到这样的例子.
这是我的代码:
private static void AddCar(Vechicle _Motor, List<Vechicle> vehicles)
{
//int number = 1;
Console.Clear();
Vechicle v = new Vechicle();
Console.Write("/////////////////////ADDING CAR DETAILS\\\\\\\\\\\\\\\\\\\\\\\\");
Console.Write("\n\nEnter Make: ");
v.Make = Console.ReadLine();
Console.Write("\n\nEnter Model: ");
v.Model = Console.ReadLine();
Console.Write("\n\nEnter Year: ");
v.Year = Console.ReadLine();
vehicles.Add(v);
Console.Clear();
foreach (Vechicle value in vehicles)
{
Console.WriteLine(vehicles);
}
}
Run Code Online (Sandbox Code Playgroud)
这是输出:

谢谢你的帮助!
我现在改变了:
foreach (Vechicle value in vehicles)
{
Console.WriteLine(vehicles);
}
Run Code Online (Sandbox Code Playgroud)
至:
foreach (Vechicle value in vehicles)
{
Console.WriteLine(value);
}
Run Code Online (Sandbox Code Playgroud)
正如评论中所建议的,但现在我明白了:
