This class was deprecated in API level 27.1.0.
use BrowseSupportFragment
But when i replaced this
public class MainFragment extends BrowseFragment
to
public class MainFragment extends BrowseSupportFragment
bellow exception is occurring
Caused by: android.app.Fragment$InstantiationException: Trying to instantiate a class MainFragment that is not a Fragment
My XML code is
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:name="com.example.tvapplocation1.MainFragment"
android:layout_width="match_parent" android:layout_height="match_parent">
</fragment>
Short answer: This can happen if your Activity does not extend from FragmentActivity.
Longer answer: There are two versions of the Fragment class, one that's built into the OS and one that's part of the support/Android X libraries (). You should always use the support/Android X version because it provides compatibility and consistent behavior across Android OS versions. The various *SupportFragment classes (like BrowseSupportFragment) extend from the support/Android X version of Fragment, which require you to use the FragmentActivity from the support/Android X libraries.
Related
I'm recently writing a javafx application and in one of its parts the client must wait for the server to get a list of people and after getting the list it must be used in a listview that is going to be added to a parent. That parent is and fxml file and after loading it I want to know if it is possible to add the vbox containing the listview to the parent or not. I'd be grateful if anyone could help...
From your question I gather you are not familiar with the idea of a controller or the associated FXML injection performed by a FXMLLoader. This answer by James_D goes over the very basics of the JavaFX lifecycle but it first goes over the basics of the procedure involved when loading a FXML file. If you want to modify the scene-graph that is loaded via FXML then you need to use a controller class with the appropriate FXML annotated fields. For example, let's say your parent is a BorderPane. In your FXML file you'd have:
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.layout.BorderPane?>
<BorderPane fx:id="parent" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/10.0.1"
fx:controller="some.package.YourController">
<top>
<!-- maybe have something like a MenuBar here -->
</top>
<bottom>
<!-- maybe have a some type of status bar here -->
</bottom>
</BorderPane>
Notice the fx:controller attribute; it is the class name of the class to instantiate and use as a controller. Also note the fx:id attribute. In your controller class you'd have:
package some.package;
import javafx.scene.layout.BorderPane;
import javafx.fxml.FXML;
public class YourController {
#FXML
private BorderPane parent; // field name matches the fx:id attribute
#FXML
private void initialize() {
// do any initializing if needed (if not, get rid of this method)
// you can access and modify any FXML injected field from this method
}
}
Then you can use the parent via the controller instance. You could also create and link event handler methods in the controller and do certain behavior based on user actions. It's important to note, however, that how you change the state of the UI in the controllers depends on how you access you model classes. You'll need to have the model available to your controller and possibly have it shared between mutliple controllers. There are a decent number of questions/answers on Stack Overflow about how to do this already.
Here is another resource that may help you: Introduction to FXML.
The Caliburn.Micro Xamarin.Forms samples (both setup and features illustrate the use of App.cs with no accompanying App.xaml.
I'd like to have an App.xaml file though so I can add in App-level resources into xaml which are now supposed in Xamarin.Forms. Is this possible? How do I do it?
Note, I haven't added one afterwards ever and this is untested, but it should work something like this.
The App.xaml was introduced later into the Xamarin.Forms packages and templates, probably due to the introduction of the app-level resources you are referring to. But basically, the App.xaml isn't different from any other XAML file.
Add a new App.xaml file which looks somewhat like this:
<?xml version="1.0" encoding="utf-8"?>
<Application xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="YourNamespace.YourClass">
<Application.Resources>
<!-- Application resource dictionary -->
</Application.Resources>
</Application>
Note that you need to supply your own namespace in the x:Class="YourNamespace.YourClass" attribute. Now in the same class that you specify here, which should be in your App.cs, make sure the class is marked as partial and the InitializeComponent(); is called in the constructor.
Lastly, make sure that your App.xaml file is marked to be an EmbeddedResource as build action.
In fact that is everything there is to it.
If you want to link your App.xaml and App.xaml.cs file so that they are shown as one node in Visual Studio, open your csproj file in a text-editor and find the <Compile Include="App.xaml.cs" /> node. Edit this to be:
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
</Compile>
While this looks nicer, it's not absolutely necessary.
Can someone please explain the real difference between ImageView and com.facebook.drawee.view.SimpleDraweeView.and why fresco not use imageview.?
can we upload a image on server through fresco? if yes please share code..
Unlike Codo's answer that discusses the "deeper" difference between these classes (see The Image Pipeline section here), I'll discuss the usability difference.
Going over the source code of SimpleDraweeView and related classes one can see the following inheritance hierarchy:
public class SimpleDraweeView extends GenericDraweeView
public class GenericDraweeView extends DraweeView<GenericDraweeHierarchy>
public class DraweeView<DH extends DraweeHierarchy> extends ImageView
The following description appears before the class definition of DraweeView:
Although ImageView is subclassed instead of subclassing View directly, this class does not support ImageView's setImageXxx, setScaleType and similar methods. Extending ImageView is a short term solution in order to inherit some of its implementation (padding calculations, etc.).
This class is likely to be converted to extend View directly in the future, so avoid using ImageView's methods and properties (T5856175).
So we know that DraweeView presently inherits from ImageView - which usually means that "it does everything ImageView does and more" (with the exceptions discussed in the comment block above). This simplistic approach can give you a general idea but ignores the most important aspect of compatibility with Fresco.
The Fresco docs explain how to use drawees, and you can see right from their XML definition that they are much more customizable than ImageView:
<com.facebook.drawee.view.SimpleDraweeView
android:id="#+id/my_image_view"
android:layout_width="20dp"
android:layout_height="20dp"
fresco:fadeDuration="300"
fresco:actualImageScaleType="focusCrop"
fresco:placeholderImage="#color/wait_color"
fresco:placeholderImageScaleType="fitCenter"
fresco:failureImage="#drawable/error"
fresco:failureImageScaleType="centerInside"
fresco:retryImage="#drawable/retrying"
fresco:retryImageScaleType="centerCrop"
fresco:progressBarImage="#drawable/progress_bar"
fresco:progressBarImageScaleType="centerInside"
fresco:progressBarAutoRotateInterval="1000"
fresco:backgroundImage="#color/blue"
fresco:overlayImage="#drawable/watermark"
fresco:pressedStateOverlayImage="#color/red"
fresco:roundAsCircle="false"
fresco:roundedCornerRadius="1dp"
fresco:roundTopLeft="true"
fresco:roundTopRight="false"
fresco:roundBottomLeft="false"
fresco:roundBottomRight="true"
fresco:roundWithOverlayColor="#color/corner_color"
fresco:roundingBorderWidth="2dp"
fresco:roundingBorderColor="#color/border_color"
/>
As for uploads - it seems like Fresco is only intended for downloading images. You might want to look into Robospice/Retrofit for your uploading needs.
Android versions before Android 5 have serious problems with handling a large number of images. Android 2 has problems if they are on the Java heap and Android 4 doesn't properly release them if you don't destroy the activity.
So Fresco moves images to the native heap (Android 2) and implements its own reference counting for Android 4 in order to know when the image is no longer reference and can be recycled.
They replace ImageView with SimpleDrawView in order to have full control about the references to the images. In fact, only there low level API gives you direct access to the image at all. Otherwise their approach with reference counting would work.
The facebook provides its own ImageView, So rather than creating your own CustomView or ImageView you can use their View.
But, Remember you could have a less control on it as compared with your own Custom View.
This gives you a complete package and Functionality for a Button, View or Anything like that.
Like this here for Rounded Corners of a ImageView
<de.hdodenhof.circleimageview.CircleImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:id="#+id/userImage"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp" />
I am trying to create a simple WPF application. However, I am keeping the views, models and bootstrapper in separate class library and calling it from a separate WPF application.
My library has just one view for main window, one MainWindow xaml class and a Bootstrapper derived class. Currently I have overloaded OnStartup
Here is my OnStartup code
protected override object GetInstance(Type serviceType, string key)
{
return base.GetInstance(serviceType, key);
}
Here is my WPF App.Xaml is calling it
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary>
<my:AppBootStrapper x:Key="bootstrapper" />
</ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
Problem is, I noticed that Bootstrapper object is created but OnStartup is never called. Why ?
Do I have to do anything extra ?
Initialize() is required in the Bootstrap Constructor
I have used the ThemeBuilder to create a theme, but now I need to add an attribute in a CSS class so I can have a different font color in the selected element of a ListView, for example.
Ideally I would expect that the builder have support for specifying such a configuration in the .theme file, specially because font color is something that will not affect the image generation process that is used to support older browsers. In fact the builder should have support for all standard CSS3 attributes that don't affect the generated images.
Obviously it is possible to modify the ThemeBuilder jar to achieve this, but this is not a good idea.
I had a look in the appearance classes that are generated and my first try was to use the following constructor:
public Css3ContentPanelAppearance(Css3ContentPanelResources resources) {
this(resources, GWT.<Css3ContentPanelTemplate> create(Css3ContentPanelTemplate.class));
}
This did not work well, because all components using Css3ContentPanelAppearance are affected regardless of which Css3ContentPanelResources was used. I believe this happens because the CSS class name is based on the appearance class name and on the CssResource class name.
The solution was very simple: create a sub-class of the generated appearance class like this:
public class CustomCss3ListViewAppearance extends Css3ListViewAppearance {
public interface CustomCss3ListViewResources extends Css3ListViewAppearance.Css3ListViewResources {
// Load the original resources first and then the custom one, so the customizations will take precedence.
#ClientBundle.Source({"com/example/client/base/listview/Css3ListView.css","CustomCss3ListView.css"})
#Override
Css3ListViewAppearance.Css3ListViewStyle css();
}
public CustomCss3ListViewAppearance() {
super(GWT.<Css3ListViewAppearance.Css3ListViewResources>create(CustomCss3ListViewResources.class));
}
}
Then, you can create a separate JAR module that depends on the generated theme, specify some bindings in the .gwt.xml file and it will behave exactly as a plain generated theme (just need to add a dependency and import it in the application .gwt.xml file):
<?xml version="1.0" encoding="UTF-8"?>
<module rename-to='myCustomTheme'>
<inherits name="com.example.Theme"/>
<replace-with class="com.example.client.base.listview.CustomCss3ListViewAppearance">
<when-type-is class="com.sencha.gxt.widget.core.client.ListView.ListViewAppearance" />
<when-property-is name="gxt.theme" value="myTheme" />
</replace-with>
<source path="myCustomTheme/client"/>
</module>