我想打电话给创建(Bundle cicici); 从其他方法然后我得到"NullPointerException",所以请指导我如何从另一个方法()调用onCreate().
public void moreFriendsButtonClick(int id)
{
contentId= id;
onCreate(tempBundle);
}
Run Code Online (Sandbox Code Playgroud)
在这里,我传递int值,和
tempBundle=savedInstanceState;
Run Code Online (Sandbox Code Playgroud)
之后我得到NullPointerException
我是Android世界的新手......如果有人纠正我,那将是一个很好的帮助...我在做错了以下代码...
cutomviewxml.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
扩展视图类...代码......
mycustomTextview.java
public class mycustomTextview extends View {
private View mView;
Context mycontext;
public mycustomTextview(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
this.mycontext = context;
LayoutInflater inflater;
inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mView = inflater.inflate(R.layout.cutomviewxml, null);
}
Run Code Online (Sandbox Code Playgroud)
Activity main.xml文件
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<com.motorola.mycustomTextview
android:id="@+id/customtextview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/textView2"
android:layout_marginLeft="143dp" …Run Code Online (Sandbox Code Playgroud) 我使用以下代码
class CustomWebViewClient extends WebViewClient {
Context context;
ProgressDialog pd = null;
public CustomWebViewClient (Context c){
context = c;
}
public void onPageFinished(WebView view, String url){
pd.dismiss();
}
public boolean shouldOverrideUrlLoading(final WebView view, final String url) {
pd = ProgressDialog.show(context, "", "pageload. Please wait...", true);
view.loadUrl(url);
return true;
}
}
Run Code Online (Sandbox Code Playgroud)
当我单击WebView中的链接时,会出现对话框并开始加载页面,但是当页面加载完毕后,对话框仍然在屏幕上.显然代码很简单,但我无法弄清楚这一点.此外,我想我应该补充一点,被点击的链接有一些重定向,但我不确定这是否与原因有关.
我怎么能这样做?