如何在DigitalOcean Kubernetes上设置Eclipse Theia Cloud IDE平台

news/2024/7/7 4:50:39

介绍 (Introduction)

With developer tools moving to the cloud, creation and adoption of cloud IDE (Integrated Development Environment) platforms is growing. Cloud IDEs are accessible from every type of modern device through web browsers, and they offer numerous advantages for real-time collaboration scenarios. Working in a cloud IDE provides a unified development and testing environment for you and your team, while minimizing platform incompatibilities. Because they are natively based on cloud technologies, they are able to make use of the cluster to achieve tasks, which can greatly exceed the power and reliability of a single development computer.

随着开发人员工具转移到云中,云IDE(集成开发环境)平台的创建和采用正在增长。 每种类型的现代设备都可以通过Web浏览器访问Cloud IDE,它们为实时协作场景提供了众多优势。 在云IDE中工作可为您和您的团队提供统一的开发和测试环境,同时最大程度地减少平台不兼容性。 因为它们本身基于云技术,所以它们能够利用群集来完成任务,这可能大大超过单个开发计算机的功能和可靠性。

Eclipse Theia is an extensible cloud IDE running on a remote server and accessible from a web browser. Visually, it’s designed to look and behave similarly to Microsoft Visual Studio Code, which means that it supports many programming languages, has a flexible layout, and has an integrated terminal. What separates Eclipse Theia from other cloud IDE software is its extensibility; it can be modified using custom extensions, which allow you to craft a cloud IDE suited to your needs.

Eclipse Theia是运行在远程服务器上的可扩展云IDE,可从Web浏览器访问。 在外观上,它的外观和行为与Microsoft Visual Studio Code相似,这意味着它支持多种编程语言,灵活的布局以及集成的终端。 Eclipse Theia与其他Cloud IDE软件的不同之处在于其可扩展性。 可以使用自定义扩展对其进行修改,从而使您可以制作适合自己需求的云IDE。

In this tutorial, you will set up the default version of the Eclipse Theia cloud IDE platform on your DigitalOcean Kubernetes cluster and expose it at your domain, secured with Let’s Encrypt certificates and requiring the visitor to authenticate. In the end, you’ll have Eclipse Theia running on your Kubernetes cluster available via HTTPS and requiring the visitor to log in.

在本教程中,您将在DigitalOcean Kubernetes集群上设置Eclipse Theia云IDE平台的默认版本,并在您的域中公开它,并使用Let's Encrypt证书进行保护,并要求访问者进行身份验证。 最后,您将通过HTTPS在Kubernetes集群上运行Eclipse Theia,并且需要访问者登录。

先决条件 (Prerequisites)

  • A DigitalOcean Kubernetes cluster with your connection configured as the kubectl default. Instructions on how to configure kubectl are shown in the Connect to your Cluster step when you create your cluster. To create a Kubernetes cluster on DigitalOcean, see Kubernetes Quickstart.

    一个DigitalOcean Kubernetes集群,其连接配置为kubectl默认。 创建集群时,“如何连接到集群”步骤中显示了有关如何配置kubectl说明。 要在DigitalOcean上创建Kubernetes集群,请参阅Kubernetes Quickstart 。

  • The Helm package manager installed on your local machine, and Tiller installed on your cluster. To do this, complete Steps 1 and 2 of the How To Install Software on Kubernetes Clusters with the Helm Package Manager tutorial.

    在本地计算机上安装了Helm软件包管理器,在集群上安装了Tiller。 为此,请使用Helm Package Manager教程完成如何在Kubernetes群集上安装软件的步骤1和2。

  • The Nginx Ingress Controller and Cert Manager installed on your cluster using Helm in order to expose Eclipse Theia using Ingress Resources. To do this, follow How to Set Up an Nginx Ingress on DigitalOcean Kubernetes Using Helm.

    使用Helm在群集上安装了Nginx Ingress Controller和Cert Manager,以便使用Ingress资源公开Eclipse Theia。 为此,请遵循如何使用Helm在DigitalOcean Kubernetes上设置Nginx入口 。

  • A fully registered domain name to host Eclipse Theia. This tutorial will use theia.your_domain throughout. You can purchase a domain name on Namecheap, get one for free on Freenom, or use the domain registrar of your choice.

    托管Eclipse Theia的完整注册域名。 本教程将始终使用theia.your_domain 。 你可以购买一个域名Namecheap ,免费获得一个在Freenom ,或使用你选择的域名注册商。

第1步-安装和公开Eclipse Theia (Step 1 — Installing and Exposing Eclipse Theia)

To begin you’ll install Eclipse Theia to your DigitalOcean Kubernetes cluster. Then, you will expose it at your desired domain using an Nginx Ingress.

首先,将Eclipse Theia安装到DigitalOcean Kubernetes集群。 然后,您将使用Nginx Ingress在所需的域中公开它。

Since you created two example deployments and a resource as part of the prerequisites, you can freely delete them by running the following commands:

由于创建了两个示例部署和一个资源作为前提条件的一部分,因此您可以通过运行以下命令来自由删除它们:

  • kubectl delete -f hello-kubernetes-ingress.yaml

    kubectl删除-f hello-kubernetes-ingress.yaml
  • kubectl delete -f hello-kubernetes-first.yaml

    kubectl删除-f hello-kubernetes-first.yaml
  • kubectl delete -f hello-kubernetes-second.yaml

    kubectl删除-f hello-kubernetes-second.yaml

For this tutorial, you’ll store the deployment configuration on your local machine, in a file named eclipse-theia.yaml. Create it using the following command:

在本教程中,您将部署配置存储在本地计算机上的eclipse-theia.yaml文件中。 使用以下命令创建它:

  • nano eclipse-theia.yaml

    纳米蚀-theia.yaml

Add the following lines to the file:

将以下行添加到文件中:

eclipse-theia.yaml
eclipse-theia.yaml
apiVersion: v1
kind: Namespace
metadata:
  name: theia
---
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: theia-next
  namespace: theia
  annotations:
    kubernetes.io/ingress.class: nginx
spec:
  rules:
  - host: theia.your_domain
    http:
      paths:
      - backend:
          serviceName: theia-next
          servicePort: 80
---
apiVersion: v1
kind: Service
metadata:
 name: theia-next
 namespace: theia
spec:
 ports:
 - port: 80
   targetPort: 3000
 selector:
   app: theia-next
---
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: theia-next
  name: theia-next
  namespace: theia
spec:
  selector:
    matchLabels:
      app: theia-next
  replicas: 1
  template:
    metadata:
      labels:
        app: theia-next
    spec:
      containers:
      - image: theiaide/theia:next
        imagePullPolicy: Always
        name: theia-next
        ports:
        - containerPort: 3000

This configuration defines a Namespace, a Deployment, a Service, and an Ingress. The Namespace is called theia and will contain all Kubernetes objects related to Eclipse Theia, separated from the rest of the cluster. The Deployment consists of one instance of the theiaide/theia:next Docker image with the port 3000 exposed on the container. The Service looks for the Deployment and remaps the container port to the usual HTTP port, 80, allowing in-cluster access to Eclipse Theia.

此配置定义了名称空间,部署,服务和入口。 命名空间称为theia ,它将包含与Eclipse Theia相关的所有Kubernetes对象,并与集群的其余部分分开。 部署由theiaide/theia:next Docker映像的一个实例组成,在容器上暴露了端口3000 。 该服务将查找Deployment,并将容器端口重新映射到通常的HTTP端口80 ,从而允许对Eclipse Theia的集群内访问。

The Ingress contains a rule to serve the Service at port 80 externally at your desired domain. In its annotations, you specify that the Nginx Ingress Controller should be used for request processing. Remember to replace theia.your_domain with your desired domain that you’ve pointed to your cluster’s Load Balancer, then save and close the file.

入口包含一个规则,可在所需域的外部端口80上服务该服务。 在其批注中,您指定应将Nginx Ingress Controller用于请求处理。 请记住,将theia.your_domain替换为您指向集群的负载均衡器的所需域,然后保存并关闭文件。

Save and exit the file.

保存并退出文件。

Then, create the configuration in Kubernetes by running the following command:

然后,通过运行以下命令在Kubernetes中创建配置:

  • kubectl create -f eclipse-theia.yaml

    kubectl创建-f eclipse-theia.yaml

You’ll see the following output:

您将看到以下输出:


   
Output
namespace/theia created ingress.networking.k8s.io/theia-next created service/theia-next created deployment.apps/theia-next created

You can watch the Eclipse Theia pod creation by running:

您可以通过运行以下命令观看Eclipse Theia pod的创建:

  • kubectl get pods -w -n theia

    kubectl获取豆荚-w -n theia

The output will look like this:

输出将如下所示:


   
Output
NAME READY STATUS RESTARTS AGE theia-next-847d8c8b49-jt9bc 0/1 ContainerCreating 0 22s

After some time, the status will turn to RUNNING, which means you’ve successfully installed Eclipse Theia to your cluster.

一段时间后,状态将变为RUNNING ,这意味着您已成功将Eclipse Theia安装到集群中。

Navigate to your domain in your browser. You’ll see the default Eclipse Theia editor GUI.

在浏览器中导航到您的域。 您将看到默认的Eclipse Theia编辑器GUI。

You’ve deployed Eclipse Theia to your DigitalOcean Kubernetes cluster and exposed it at your desired domain with an Ingress. Next, you’ll secure access to your Eclipse Theia deployment by enabling login authentication.

您已经将Eclipse Theia部署到了DigitalOcean Kubernetes集群,并通过Ingress将其公开在所需的域中。 接下来,您将通过启用登录身份验证来保护对Eclipse Theia部署的访问。

步骤2 —为您的域启用登录身份验证 (Step 2 — Enabling Login Authentication For Your Domain)

In this step, you’ll enable username and password authentication for your Eclipse Theia deployment. You’ll achieve this by first curating a list of valid login combinations using the htpasswd utility. Then, you’ll create a Kubernetes secret containing that list and configure the Ingress to authenticate visitors according to it. In the end, your domain will only be accessible when the visitor inputs a valid username and password combination. This will prevent guests and other unwanted visitors from accessing Eclipse Theia.

在此步骤中,您将为Eclipse Theia部署启用用户名和密码认证。 首先,使用htpasswd实用工具htpasswd有效的登录组合列表,以实现此目的。 然后,您将创建一个包含该列表的Kubernetes机密,并配置Ingress以根据该身份验证访问者。 最后,只有当访问者输入有效的用户名和密码组合时,才能访问您的域。 这将防止来宾和其他不需要的访客访问Eclipse Theia。

The htpasswd utility comes from the Apache web server and is used for creating files that store lists of login combinations. The format of htpasswd files is one username:hashed_password combination per line, which is the format the Nginx Ingress Controller expects the list to conform to.

htpasswd实用程序来自Apache Web服务器,用于创建存储登录组合列表的文件。 htpasswd文件的格式是每行一个username:hashed_password组合,这是Nginx Ingress Controller希望列表符合的格式。

Start by installing htpasswd on your system by running the following command:

首先通过运行以下命令在系统上安装htpasswd

  • sudo apt install apache2-utils -y

    须藤apt install apache2-utils -y

You’ll store the list in a file called auth. Create it by running:

您会将列表存储在名为auth的文件中。 通过运行以下命令创建它:

  • touch auth

    触摸身份验证

This file needs to be named auth because the Nginx Ingress Controller expects the secret to contain a key called data.auth. If it’s missing, the controller will return HTTP 503 Service Unavailable status.

该文件需要命名为auth因为Nginx Ingress Controller希望密钥包含一个名为data.auth的密钥。 如果丢失,控制器将返回HTTP 503 Service Unavailable状态。

Add a username and password combination to auth by running the following command:

通过运行以下命令将用户名和密码组合添加到auth

  • htpasswd auth username

    htpasswd身份验证用户名

Remember to replace username with your desired username. You’ll be asked for an accompanying password and the combination will be added into the auth file. You can repeat this command for as many users as you wish to add.

请记住将username替换为所需的用户名。 系统将要求您提供密码,密码将被添加到auth文件中。 您可以为希望添加的用户重复此命令。

Note: If the system you are working on does not have htpasswd installed, you can use a Dockerized version instead.

注意:如果您正在使用的系统未安装htpasswd ,则可以改用Dockerized版本。

You’ll need to have Docker installed on your machine. For instructions on how to do so, visit the official docs.

您需要在计算机上安装Docker。 有关如何操作的说明,请访问官方文档 。

Run the following command to run a dockerized version:

运行以下命令以运行dockerized版本:

  • docker run --rm -it httpd htpasswd -n <username>

    泊坞窗运行--rm -it httpd htpasswd -n <用户名>

Remember to replace <username> with the username you want to use. You’ll be asked for a password. The hashed login combination will be written out on the console, and you’ll need to manually add it to the end of the auth file. Repeat this process for as many logins as you wish to add.

请记住用您要使用的用户名替换<username> 。 系统将要求您输入密码。 哈希登录组合将在控制台上写出,您需要手动将其添加到auth文件的末尾。 对要添加的登录名重复此过程。

When you are done, create a new secret in Kubernetes with the contents of the file by running the following command:

完成后,通过运行以下命令在Kubernetes中使用文件内容创建一个新密码:

  • kubectl create secret generic theia-basic-auth --from-file=auth -n theia

    kubectl创建秘密的通用theia-basic-auth --from-file = auth -n theia

You can see the secret with:

您可以通过以下方式查看秘密:

  • kubectl get secret theia-basic-auth -o yaml -n theia

    kubectl获取秘密theia-basic-auth -o yaml -n theia

The output will look like:

输出将如下所示:


   
Output
apiVersion: v1 data: auth: c2FtbXk6JGFwcjEkVFMuSDdyRWwkaFNSNWxPbkc0OEhncmpGZVFyMzEyLgo= kind: Secret metadata: creationTimestamp: "..." name: theia-basic-auth namespace: default resourceVersion: "10900" selfLink: /api/v1/namespaces/default/secrets/theia-basic-auth uid: 050767b9-8823-4fd3-b498-5f11074f768b type: Opaque

Next, you’ll need to edit the Ingress to make it use the secret. Open the deployment configuration for editing:

接下来,您需要编辑Ingress以使其使用密码。 打开部署配置以进行编辑:

  • nano eclipse-theia.yaml

    纳米蚀-theia.yaml

Add the highlighted lines to your file:

将突出显示的行添加到您的文件中:

eclipse-theia.yaml
eclipse-theia.yaml
apiVersion: v1
kind: Namespace
metadata:
  name: theia
---
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: theia-next
  namespace: theia
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/auth-type: basic
    nginx.ingress.kubernetes.io/auth-secret: theia-basic-auth
    nginx.ingress.kubernetes.io/auth-realm: 'Authentication Required - Eclipse Theia'
spec:
  rules:
  - host: theia.your_domain
    http:
      paths:
      - backend:
          serviceName: theia-next
          servicePort: 80
...

First, in the auth-type annotation, you specify that the authentication type is basic. This means that Nginx will require the user to type in a username and password. Then, in auth-secret, you specify that the secret that contains the list of valid combinations is theia-basic-auth, which you’ve just created. The remaining auth-realm annotation specifies a message that will be shown to the user as an explanation of why authentication is required. You can change the message contained in this field to your liking.

首先,在auth-type批注中,指定身份验证类型为basic 。 这意味着Nginx将要求用户输入用户名和密码。 然后,在auth-secret ,指定包含有效组合列表的密码是刚刚创建的theia-basic-auth 。 其余的auth-realm批注指定一条消息,该消息将显示给用户,以解释为什么要求进行身份验证。 您可以根据自己的喜好更改此字段中包含的消息。

Save and close the file.

保存并关闭文件。

To propagate the changes to your cluster, run the following command:

要将更改传播到集群,请运行以下命令:

  • kubectl apply -f eclipse-theia.yaml

    kubectl apply -f eclipse-theia.yaml

You’ll see the output:

您将看到输出:


   
Output
namespace/theia unchanged ingress.networking.k8s.io/theia-next configured service/theia-next unchanged deployment.apps/theia-next unchanged

Navigate to your domain in your browser, where you’ll now be asked to log in.

在浏览器中导航到您的域,现在将要求您登录。

You’ve enabled basic login authentication on your Ingress by configuring it to use the secret containing the hashed username and password combinations. In the next step, you’ll secure access further by adding TLS certificates, so that the traffic between you and your Eclipse Theia deployment stays encrypted.

通过在Ingress上启用基本登录身份验证,方法是将其配置为使用包含哈希用户名和密码组合的机密。 在下一步中,您将通过添加TLS证书进一步保护访问,从而使您和Eclipse Theia部署之间的通信保持加密状态。

步骤3 —应用让我们加密HTTPS证书 (Step 3 — Applying Let’s Encrypt HTTPS Certificates)

Next you will secure your Eclipse Theia installation by applying Let’s Encrypt certificates to your Ingress, which Cert-Manager will automatically provision. After completing this step, your Eclipse Theia installation will be accessible via HTTPS.

接下来,通过将“加密”证书应用于Ingress(由Cert-Manager自动配置)来保护Eclipse Theia的安装。 完成此步骤后,您可以通过HTTPS访问Eclipse Theia安装。

Open eclipse-theia.yaml for editing:

打开eclipse-theia.yaml进行编辑:

  • nano eclipse-theia.yaml

    纳米蚀-theia.yaml

Add the highlighted lines to your file, making sure to replace the placeholder domain with your own:

将突出显示的行添加到文件中,确保将占位符域替换为您自己的占位符域:

eclipse-theia.yaml
eclipse-theia.yaml
apiVersion: v1
kind: Namespace
metadata:
  name: theia
---
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: theia-next
  namespace: theia
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/auth-type: basic
    nginx.ingress.kubernetes.io/auth-secret: theia-basic-auth
    nginx.ingress.kubernetes.io/auth-realm: 'Authentication Required - Eclipse Theia'
    cert-manager.io/cluster-issuer: letsencrypt-prod
spec:
  tls:
  - hosts:
    - theia.your_domain
    secretName: theia-prod
  rules:
  - host: theia.your_domain
    http:
      paths:
      - backend:
          serviceName: theia-next
          servicePort: 80
...

First, you specify the letsencrypt-prod ClusterIssuer you created as part of the prerequisites as the issuer that will be used to provision certificates for this Ingress. Then, in the tls section, you specify the exact domain that should be secured, as well as a name for a secret that will be holding those certificates.

首先,您指定作为先决条件的一部分而创建的letsencrypt-prod ClusterIssuer,作为将用于为此Ingress设置证书的颁发者。 然后,在tls部分中,指定应该保护的确切域,以及将保存这些证书的机密的名称。

Save and exit the file.

保存并退出文件。

Apply the changes to your cluster by running the following command:

通过运行以下命令将更改应用于集群:

  • kubectl apply -f eclipse-theia.yaml

    kubectl apply -f eclipse-theia.yaml

The output will look like:

输出将如下所示:


   
Output
namespace/theia unchanged ingress.networking.k8s.io/theia-next configured service/theia-next unchanged deployment.apps/theia-next unchanged

It will take a few minutes for the certificates to be provisioned and fully applied. You can track the progress by observing the output of the following command:

设置和完全应用证书将需要几分钟。 您可以通过观察以下命令的输出来跟踪进度:

  • kubectl describe certificate theia-prod -n theia

    kubectl描述证书theia-prod -n theia

When it finishes, the end of the output will look similar to this:

完成后,输出的结尾将类似于以下内容:


   
Output
... Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal GeneratedKey 42m cert-manager Generated a new private key Normal Requested 42m cert-manager Created new CertificateRequest resource "theia-prod-3785736528" Normal Issued 42m cert-manager Certificate issued successfully

Refresh your domain in your browser. You’ll see a green padlock shown on the leftmost side of the address bar signifying that the connection is secure.

在浏览器中刷新您的域。 您会在地址栏的最左侧看到一个绿色的挂锁,表示该连接是安全的。

You’ve configured the Ingress to use Let’s Encrypt certificates thus making your Eclipse Theia deployment more secure. Now you can review the default Eclipse Theia user interface.

您已将Ingress配置为使用“让我们加密”证书,从而使Eclipse Theia部署更加安全。 现在,您可以查看默认的Eclipse Theia用户界面。

第4步—使用Eclipse Theia界面 (Step 4 — Using the Eclipse Theia Interface)

In this section, you’ll explore some of the features of the Eclipse Theia interface.

在本节中,您将探索Eclipse Theia界面的一些功能。

On the left-hand side of the IDE, there is a vertical row of four buttons opening the most commonly used features in a side panel.

在IDE的左侧,有一排垂直的四个按钮,用于打开侧面板中最常用的功能。

This bar is customizable so you can move these views to a different order or remove them from the bar. By default, the first view opens the Explorer panel that provides tree-like navigation of the project’s structure. You can manage your folders and files here—creating, deleting, moving, and renaming them as necessary.

该栏是可自定义的,因此您可以将这些视图移动到其他顺序或从栏中删除它们。 默认情况下,第一个视图打开“资源管理器”面板,该面板提供了项目结构的树状导航。 您可以在此处管理文件夹和文件-根据需要创建,删除,移动和重命名它们。

After creating a new file through the File menu, you’ll see an empty file open in a new tab. Once saved, you can view the file’s name in Explorer side panel. To create folders right click on the Explorer sidebar and click on New Folder. You can expand a folder by clicking on its name as well as dragging and dropping files and folders to upper parts of the hierarchy to move them to a new location.

通过“ 文件”菜单创建新文件后,您会在新标签页中看到一个空文件。 保存后,您可以在资源管理器侧面板中查看文件的名称。 要创建文件夹,请右键单击资源管理器侧栏,然后单击“ 新建文件夹” 。 您可以通过以下方式展开文件夹:单击文件夹的名称,然后将文件和文件夹拖放到层次结构的上部,以将其移动到新位置。

The next two options provide access to search and replace functionality. Following it, the next one provides a view of source control systems that you may be using, such as Git.

接下来的两个选项提供对搜索和替换功能的访问。 在它之后,下一个视图提供了您可能正在使用的源代码控制系统的视图,例如Git 。

The final view is the debugger option, which provides all the common actions for debugging in the panel. You can save debugging configurations in the launch.json file.

最终视图是debugger选项,该选项提供面板中所有常用的调试操作。 您可以将调试配置保存在launch.json文件中。

The central part of the GUI is your editor, which you can separate by tabs for your code editing. You can change your editing view to a grid system or to side-by-side files. Like all modern IDEs, Eclipse Theia supports syntax highlighting for your code.

GUI的中央部分是您的编辑器,您可以通过选项卡将其分开以进行代码编辑。 您可以将编辑视图更改为网格系统或并排文件。 与所有现代IDE一样,Eclipse Theia支持代码的语法高亮显示。

You can gain access to a terminal by typing CTRL+SHIFT+`, or by clicking on Terminal in the upper menu, and selecting New Terminal. The terminal will open in a lower panel and its working directory will be set to the project’s workspace, which contains the files and folders shown in the Explorer side panel.

您可以通过键入访问终端CTRL+SHIFT+`或通过单击码头上的菜单,并选择新航站楼 。 终端将在下面的面板中打开,其工作目录将设置为项目的工作区,其中包含“资源管理器”侧面板中显示的文件和文件夹。

You’ve explored a high-level overview of the Eclipse Theia interface and reviewed some of the most commonly used features.

您已经浏览了Eclipse Theia界面的高级概述,并回顾了一些最常用的功能。

结论 (Conclusion)

You now have Eclipse Theia, a versatile cloud IDE, installed on your DigitalOcean Kubernetes cluster. You’ve secured it with a free Let’s Encrypt TLS certificate and set up the instance to require a login from the visitor. You can work on your source code and documents with it individually or collaborate with your team. You can also try building your own version of Eclipse Theia if you need additional functionality. For further information on how to do that, visit the Theia docs.

现在,您已经在DigitalOcean Kubernetes集群上安装了多功能的云IDE Eclipse Theia。 您已经使用免费的Let's Encrypt TLS证书保护了它的安全,并设置了实例以要求访问者登录。 您可以单独使用源代码和文档,也可以与团队合作。 如果需要其他功能,也可以尝试构建自己的Eclipse Theia版本。 有关如何执行此操作的更多信息,请访问Theia docs 。

翻译自: https://www.digitalocean.com/community/tutorials/how-to-set-up-the-eclipse-theia-cloud-ide-platform-on-digitalocean-kubernetes


http://www.niftyadmin.cn/n/3649124.html

相关文章

Android中View绘制不同状态背景图片原理以及StateListDrawable使用详解

1、View的几种不同状态属性2、如何根据不同状态去切换我们的背景图片。开篇介绍&#xff1a;android背景选择器selector用法汇总对Android开发有经验的同学&#xff0c;对 <selector>节点的使用一定很熟悉&#xff0c;该节点的作用就是定义一组状态资源图片&#xff0c;使…

django中的app_如何在Django中构建Weather App

django中的app介绍 (Introduction) In this article we’ll build a simple Django app that displays the current weather for various cities. To get the current weather data, we’ll use the Open Weather Map API. 在本文中&#xff0c;我们将构建一个简单的Django应用…

酷炫轮播广告

一、广告轮播条的简介 广告轮播条在HTML网页设计以及APP界面设计中非常常见&#xff0c;如下图所示。在Android中&#xff0c;实现的方式可以是自定义ViewPager来实现&#xff0c;但是我们程序员中流传的一句名言&#xff0c;“不要重复造轮子”。因此我们也可以通过网上已经有…

android View 详解

一、View 的概述 android.View.View(即View)类是以矩形的方式显示在屏幕上&#xff0c;View是用户界面控件的基础。View的继承层次关系如下图&#xff1a; 可以看到所有的界面控件都是View的子类。简单证实一下&#xff0c;每当你用findViewByIds(R.id.xx)时总要将其强转&#…

“大整数阶乖”问题的递推算法

/**//* 标题&#xff1a;<<系统设计师>>应试编程实例-[递推算法程序设计]作者&#xff1a;成晓旭时间&#xff1a;2002年09月11日(11:52:00-16:26:00)实现递推算法的大整数阶乖处理函数时间&#xff1a;2002年09月16日(18:38:00-20:02:00)实现“斐波那契数列”问…

RecycleView的详细介绍

一、RecycleView的简介 RecyclerView是一种新的视图组&#xff0c;目标是为任何基于适配器的视图提供相 似的渲染方式。该控件用于在有限的窗口中展示大量数据集&#xff0c;它被作为ListView和GridView控件的继承者。 那么有了ListView、GridView为什么还需要RecyclerView这…

[人物]USTC十大IT精英

【科大精英】张亚勤 微软全球副总裁1999年加盟微软亚洲研究院(原微软中国研究院)&#xff0c;现任微软亚洲研究院院长兼首席科学家。张博士1966年出生于山西太原&#xff0c;12岁考入中国科技大学少年班&#xff0c;23岁获得美国乔治华盛顿大学电气工程博士学位(1989)&#xff…

CardView的简单使用

一、CardView的简介 CardView继承自FrameLayout类&#xff0c;可以在一个卡片布局中一致性的显示内容&#xff0c;卡片可以包含圆角和阴影&#xff0c;这是CardView的最大的卖点。CardView是一个Layout&#xff0c;可以布局其他View。 CardView常用属性&#xff1a; card_view…